Closed as not planned
Closed as not planned
Description
Due to stdlib/_collections_abc.pyi
importing most directly from stdlib/typing.pyi
, MappingView and its subclasses are missing the self._mapping
attribute. This is an issue if inheriting from them for implementing custom views. This causes pyright and mypy (with --check-untyped-defs
) to fail.
Minimal Example:
import collections.abc
class MyView(collections.abc.KeysView):
def __iter__(self):
for key in self._mapping:
yield key + 1
mypy --check-untyped-defs test.py
test.py:5: error: "MyView" has no attribute "_mapping"
pyright test.py
test.py
test.py:5:25 - error: Cannot access member "_mapping" for type "MyView"
Member "_mapping" is unknown (reportGeneralTypeIssues)
1 error, 0 warnings, 0 informations
I'm open to trying to PR this myself, though I have little experience writing stub files.
Metadata
Metadata
Assignees
Labels
No labels