It worked in PyCharm 2016 but it didn't in PyCharm 2017:
"Solution":
PyCharm 2017.2.x support NamedTuple
from typing
and I do not need to use .pyi
files anymore.
EDIT #1:
I found this issue: https://youtrack.jetbrains.com/issue/PY-18597 and there is an answer:
PyCharm 2017.1 EAP builds now always prefer stub files over Python files found on the Python path.
Meaning that Pycharm will look for what exists in a .pyi
file if such a file exists and it will use only this as reference. So you don't have another option but to declare all your functions in the .pyi file.
You can find some knowledge on how to avoid potentially annoying warnings and errors in here
EDIT #2:
Yes I can confirm that from ... import *
does not work as expected in PyCharm and that may be a bug which you can open an Issue for (or if someone succeeded in making this work, please do tell us how)!
I found a workaround based on this quote:
Modules and variables imported into the stub are not considered exported from the stub unless the import uses the import ... as ... form or the equivalent from ... import ... as ... form.
If you: from file_a import a as a, b as b ...
then everything gets unmarked as expected, but at from file_a ...
will give you the following warning:
Import resolves to its containing file... (Ctrl+F1)
This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items.
Don't be alarmed, as explained here it is a warning about possible shadowing of a module name by your file name (which does not apply in your case!)