-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
invalid syntax error #3
Comments
This issue is fixed in version I will close this issue, feel free to reopen it in case when issue still occurs in a new version. |
using v1.6
|
@sinancetinkaya Can you please provide more information? |
import asyncio
import os
import aiohttp
import pyppeteer
loop = asyncio.get_event_loop()
async def main():
os.system("start chrome --remote-debugging-port=9222")
async with aiohttp.ClientSession() as session:
try:
async with session.get("http://127.0.0.1:9222/json/version") as response:
chrome = await response.json()
except aiohttp.ClientConnectorError:
return
browser = await pyppeteer.launcher.connect(
loop=loop,
browserWSEndpoint=chrome['webSocketDebuggerUrl']
)
page = await browser.newPage()
await page.goto('https://tr.tradingview.com')
print(await page.evaluate(""" navigator.webdriver """))
await browser.close()
loop.run_until_complete(main()) for instance when I try to evaluate |
Hi @sinancetinkaya, This issue has been fixed at version I will close this issue, in case if it appears again please reopen this issue. |
I see. You using Windows OS and I didn't test it on it. Basically, the plugin creates a script that patches I am so sorry that you are receiving errors, I am trying to do my best, but there are no good documentation and tutorials regarding plugin development😔 |
You don't need to pardon for a volunteer work. I'm just trying to help you on your plugin |
Looks like I have fixed this issue. |
I'm using Windows too. I think the plugin cannot write to protected (system) "Program Files" directory. The program needs administrator rights for this. In my case I use another directory for installed programs ( |
@espdev Thanks for your time and especially for finding the root cause of the problem. The solutions which I see:
|
Can the plugin write the helper files to PyCharm settings directory?
For example:
Maybe we can use some directory in the settings directory to store the plugin data and helper python code? |
@espdev Thanks, it's a great idea, we definitely should use this directory. I will update code to use this approach. |
This issue must be fixed in version Thank you for your time and efforts 💫 @sinancetinkaya I won't close this issue until you verify that everything works on your computer 😊 |
According to @espdev 's suggestion, reinstalled PyCharm to another drive. |
@sinancetinkaya Can you please provide more context? I have tried to make async request using |
Try this. Btw this code won't work until you disable your plugin. You don't have a running event loop in your sample. It should not work at all. import aiohttp
import asyncio
loop = asyncio.get_event_loop()
async def main():
async with aiohttp.ClientSession() as session:
async with session.get("https://jsonplaceholder.typicode.com/todos/1") as response:
print(await response.json())
loop.run_until_complete(main())
loop.close() |
I have updated code to disable SSL verification: import aiohttp
import asyncio
loop = asyncio.get_event_loop()
async def main():
async with aiohttp.ClientSession() as session:
async with session.get("https://jsonplaceholder.typicode.com/todos/1", verify_ssl=False) as response:
print(await response.json())
loop.run_until_complete(main())
loop.close() And it works as expected.
Actually, it will work because plugin patches Basically, when you are trying to evaluate async code, it actually will be translated from this: await foo() to smth like this import asyncio
async def _async_func():
return await foo()
asyncio.get_event_loop().run_until_completed(_async_func()) So in case, where there no event loop it will be created, it allows to use Just to clarify, have you updated to the latest available version or you are using dev version of plugin which I have posted several messages above? |
That code should work without |
that simple code works fine 👍 |
Hmm, let me think. As far as I know, you are using python 3.9 (I am using the same version). Can you please provide:
And I will try to reproduce this isssue |
My actual code is a lot more complex and I can't post it here. Try the code I gave you.
|
Thanks, I will try to reproduce this issue. Also, I will try to get Windows OS to check if it's a platform issue. |
@espdev Can you please check if you can reproduce this issue? Because I can't reproduce this issue on my computer. |
@uriyyo I have tried to run the example with aiohttp. There are two issues on Windows.
On Windows we need to use The code sample: import asyncio
import aiohttp
async def main():
async with aiohttp.ClientSession() as session: # <-- breakpoint here
async with session.get("https://jsonplaceholder.typicode.com/todos/1") as response:
print(await response.json())
if __name__ == '__main__':
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
asyncio.run(main()) |
@espdev Thank you very much. Now somehow, I must get Windows OS and fix this issue) |
@sinancetinkaya This issue is fixed in version I have tested it on Windows OS with test cases that you provided and now everything works as expected. I am waiting for your feedback🙂 @espdev Thank you for your efforts, and especially regarding the usage of |
Hi @sinancetinkaya, new version Could you please verify that this issue is no longer present? |
at least I'm not getting any errors in the evaluation window but I don't see |
Can you try to assign it to another variable name? The problem might be that this name is used in |
Aha, you are right! Interesting... That's not the normal behavior but it's trivial |
I totally agree, but let's create a separate issue regarding this minor problem and finally close this one) |
I'm using pyppeteer
The text was updated successfully, but these errors were encountered: