pep604 from __future__ import annotations

I read about pep604 on this blog post: https://adamj.eu/tech/2021/05/21/python-type-hints-how-to-upgrade-syntax-with-pyupgrade/

I am trying to get it working in pycharm, but it doesn't seem to work:

from __future__ import annotations

a: str | None = None
~

This results in an "problem" appearing at the pipe symbol:

Class 'type' does not define '__or__', so the '|' operator cannot be used on its instances

Is this simply not supported in Pycharm or should I tweak some setting somewhere ?

Thanks !

Sander.

 

1 comment
Comment actions Permalink

Hello, 

 

It is not supported yet, please see https://youtrack.jetbrains.com/issue/PY-46779 and vote in order to be updated on resolution. 

 

I apologize for the inconvenience.

0

Please sign in to leave a comment.