Unresolved reference 'match' - Python Version 3.11.1

I wanted to use the new 'match-case' statement added in python 3.10 (previously installed 3.8) so i installed it and added a new interpreter in the settings.

The match-case statement does work now, but i still get all of it flagged in PyCharm.

Simple code example from stackoverflow for testing purposes and added version check.
Version is '3.11.1 (tags/v3.11.1:a7a450f, Dec  6 2022, 19:58:39)'

Is there any fix for this?

from sys import version
print('version =', version)
def f(x):
match x:
case 'a':
return 1
case 'b':
return 2
case _:
return 3
print(f('c'))
0
3 comments

Hello Sherwin,

Probably inspection for another version of Python is turned on. 

Please navigate **Settings | Editor | Inspections | Python**, find the "Code is incompatible with a specific version of Python", and check what versions of Python are selected in the window's bottom-right corner. Once you choose the correct version, the warning should disappear. 

If the problem persists, please also try **File | Invalidate caches**.

0

I did as Daniil sayd, but it didnt work for me. Any other ideas?

0

Please try workaround from this comment

0

Please sign in to leave a comment.