PyCharm 2019.3 does lookup for module attributes from yarl/__init__.pyi and as Query and QueryVariable are declared there, it assumes they exist in the yarl/__init__.py, but those two type variables are not declared there. So doing: from yarl import Query, QueryVariable is totally legal for PyCharm, but will throw ImportError in runtime.
As Query and QueryVariable sound very much like they're part of API, I think, it will be a rational move to solve this issue.
Naive solutions:
- Declare
__all__ in .pyi, which didn't work out for me
- Add
_ prefix to Query and QueryVariable making them "protected members" of interface file.
- Declare same types in
__init__.py. I don't think this is a good idea.
PyCharm 2019.3 does lookup for module attributes from
yarl/__init__.pyiand asQueryandQueryVariableare declared there, it assumes they exist in theyarl/__init__.py, but those two type variables are not declared there. So doing:from yarl import Query, QueryVariableis totally legal for PyCharm, but will throwImportErrorin runtime.As
QueryandQueryVariablesound very much like they're part of API, I think, it will be a rational move to solve this issue.Naive solutions:
__all__in.pyi, which didn't work out for me_prefix toQueryandQueryVariablemaking them "protected members" of interface file.__init__.py. I don't think this is a good idea.