Add stubs for importlib.(resources.)simple#10931
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| @@ -4,6 +4,7 @@ | |||
|
|
|||
There was a problem hiding this comment.
Not a matter for this PR, but at runtime (at least on main) this file re-exports code from importlib.resources.readers, so ideally we should do the same in our stub.
There was a problem hiding this comment.
Yeah, see the comments on lines 1-3 of this file :)
| def open(self, *args: Never, **kwargs: Never) -> NoReturn: ... # type: ignore[override] | ||
| def joinpath(self, *descendants: str) -> Traversable: ... | ||
|
|
||
| class TraversableReader(TraversableResources, SimpleReader, metaclass=abc.ABCMeta): |
There was a problem hiding this comment.
Why do we need the metaclass? Doesn't seem to exist at runtime.
There was a problem hiding this comment.
It inherits from a class that has abstract methods, but does not implement those abstract methods, meaning it is still abstract. Because it's really easy to do that accidentally in a stub, mypy has an undocumented feature that says you have to explicitly redeclare the metaclass if that's really what you want: https://github.com/python/mypy/blob/9011ca8b4dedc0e7177737b5265f69694afa91b5/mypy/semanal_classprop.py#L94
There was a problem hiding this comment.
Oh yes, I implemented that feature :)
|
Aha, I see pre-commit is now doing the same thing to me here that it's doing to @hamdanal in #10721 🙃 See #10939 (review) for explanation... |
This comment has been minimized.
This comment has been minimized.
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
And do some minor cleanup of
importlib.(resources.)readersfollowing 1c184fe