-1

hi I just installed windows 11 and python 3.10 and pycharm 2021.2.2 now when I use python 3.10 in pycharm and use some new features in python 3.10 i get some highlight in my code but the code is working fine here is what I'm experiencing :

syntax error highlight in pycharm 2021.2 and python 3.10

i really don't have any idea to how to fix it help please

HadiH2o
  • 302
  • 2
  • 18
  • 3
    Python 3.10 was released just yesterday. Do not expect that all introspection of code will work from day 1 (literally). In any case, PyCharm use Python to run the code, so you get no error on running the code, just syntax check is not yet ready for all cases. – Giacomo Catenazzi Oct 05 '21 at 11:51
  • 1
    Parenthesized context managers allow for continuation across multiple lines. In your case *with open(...) as a, open(...) as b* on one line will give the same functionality –  Oct 05 '21 at 12:11
  • 1
    This syntax is not yet supported in PyCharm - see the dedicated ticket https://youtrack.jetbrains.com/issue/PY-42200 – Pavel Karateev Oct 06 '21 at 11:57

2 Answers2

0

Try removing the parenthesis, and:

with open(file = "file1") as file1, open(file="file2") as file2:
    print(file1)
    print(file2)

Works for me, p.s. I'm using PyCharm 2021.2.2 Professional Edition on Ubuntu.

  • 2
    But this is not a solution. Python10 allows us to use the parenthesis, you are just using the old syntax. https://bugs.python.org/issue12782 – Giacomo Catenazzi Oct 05 '21 at 13:09
0

As mentioned by Pavel Karateev in the comments, this is a bug in PyCharm, still as of 2022-03-09.

All we can do is vote for and await the resolution of issue PY-42200.

gertvdijk
  • 24,056
  • 6
  • 41
  • 67