PyCharm incorrectly includes pycharm-community-2017.3.3/helpers/typeshed/stdlib/3/typing.pyi instead of built-in typing

Answered

The code runs ok, but the IDE shows red error waves on 

from typing.re import Pattern

If I click typing, I goes to pycharm-community-2017.3.3/helpers/typeshed/stdlib/3/typing.pyi instead of built-in typing

Anyway to resolve this? I am working on ubuntu and using pycharm-community-2017.3.3 with python 3.6

0
4 comments

Yes, we navigate to .pyi stub for a module if any exists. You can easily jump back to the respective definition using the small asterisk icon in the gutter. The problem here is that for some reason they decided not to include a proper stub for typing.re in typeshed, and in typing.py itself it's intialized in a dynamic fashion that we wouldn't be able to comprehend in our code analysis anyway at the moment. As a workaround, could you please import Pattern and Match types directly from typing instead?

0
Avatar
Permanently deleted user

I am having this issue too, and it's frustrating that the .pyi reference doesn't contain all the same functionality as the builtin. For instance, I am using the 'ForwardRef' import from built-in typing in python 3.7. Pycharm is correctly set up to use the python 3.7 interpreter in my project's virtualenv. If I enter the python console I can successfully import 'ForwardRef' from typing, but the IDE itself flags that as a reference error.

Is there something I should update in order to include full support parity for 3.7's built-in typing module?

 

0

@Tom

PyCharm uses typeshed and from what I can see there are no stubs for ForwardRef.

0
Avatar
Permanently deleted user

Thanks. I didn't know the name of the module being used. So, I guess contributing to typeshed is the only way to get that parity for now. However,  ignoring the error also works in the interim.

0

Please sign in to leave a comment.