Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2k
Don't ignore missing stubs in setuptools#10058
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't ignore missing stubs in setuptools #10058
Uh oh!
There was an error while loading. Please reload this page.
Conversation
Avasam commented Apr 17, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Uh oh!
There was an error while loading. Please reload this page.
| def __enter__(self) -> None: ... | ||
| def __exit__(self, _exc_type, _exc_value, _traceback) -> None: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are unannotated, but I don't think that should imply None since the body is just ....
AvasamApr 29, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it fine if all setuptool classes that implement the EditableStrategy protocol have the same return type for their methods? (None for __call__ and __exit__, Self for __enter__)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe for __exit__, but it feels too restrictive for __enter__.
| path_entries: Incomplete | ||
| def __init__(self, dist: Distribution, name: str, path_entries: list[Path]) -> None: ... | ||
| def __call__(self, wheel: _WheelFile, files: list[str], mapping: dict[str, str]): ... | ||
| def __enter__(self): ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| def__enter__(self): ... | |
| def__enter__(self)->Self: ... |
(Plus import)
| build_lib: Incomplete | ||
| def __init__(self, dist: Distribution, name: str, auxiliary_dir: _Path, build_lib: _Path) -> None: ... | ||
| def __call__(self, wheel: _WheelFile, files: list[str], mapping: dict[str, str]): ... | ||
| def __enter__(self): ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| def__enter__(self): ... | |
| def__enter__(self)->Self: ... |
| __all__ = ["Require", "find_module", "get_module_constant", "extract_constant"] | ||
| def find_module(module, paths=None) -> tuple[IO[Any], str, tuple[str, Literal["", "r", "rb"], Literal[7, 6, 1, 2, 3, -1]]]: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| deffind_module(module, paths=None) ->tuple[IO[Any], str, tuple[str, Literal["", "r", "rb"], Literal[7, 6, 1, 2, 3, -1]]]: ... | |
| deffind_module(module, paths=None) ->tuple[IO[Any], str|None, tuple[str, Literal["", "r", "rb"], Literal[7, 6, 1, 2, 3, -1]]]: ... |
I see some paths where it's None.
AlexWaygood left a comment • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't finish looking at this, but here's a partial review I started -- mostly a few suggestions for some type annotations that look fairly obvious :)
| requirements: Iterable[Requirement], | ||
| env: Environment | None = None, | ||
| installer: _InstallerType | None = None, | ||
| replace_conflicting=False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| replace_conflicting=False, | |
| replace_conflicting: bool=False, |
| ) -> list[Distribution]: ... | ||
| def add(self, dist: Distribution, entry: str | None = None, insert: bool = True, replace: bool = False) -> None: ... | ||
| def subscribe(self, callback: Callable[[Distribution], object]) -> None: ... | ||
| def subscribe(self, callback: Callable[[Distribution], object], existing=True) -> None: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| defsubscribe(self, callback: Callable[[Distribution], object], existing=True) ->None: ... | |
| defsubscribe(self, callback: Callable[[Distribution], object], existing: bool=True) ->None: ... |
| # TODO: change this to packaging.markers.Marker | None once we can import | ||
| # packaging.markers | ||
| marker: Incomplete | None | ||
| def __init__(self, requirement_string) -> None: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'll be the same as https://github.com/pypa/packaging/blob/55584fb5ca327ba38b74ca5c668125caaebd9a5d/src/packaging/requirements.py#L33
| def__init__(self, requirement_string) ->None: ... | |
| def__init__(self, requirement_string: str) ->None: ... |
| def __lt__(self, other) -> bool: ... | ||
| def __le__(self, other) -> bool: ... | ||
| def __gt__(self, other) -> bool: ... | ||
| def __ge__(self, other) -> bool: ... | ||
| def __eq__(self, other) -> bool: ... | ||
| def __ne__(self, other) -> bool: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| def__lt__(self, other) ->bool: ... | |
| def__le__(self, other) ->bool: ... | |
| def__gt__(self, other) ->bool: ... | |
| def__ge__(self, other) ->bool: ... | |
| def__eq__(self, other) ->bool: ... | |
| def__ne__(self, other) ->bool: ... | |
| def__lt__(self, other: Distribution) ->bool: ... | |
| def__le__(self, other: Distribution) ->bool: ... | |
| def__gt__(self, other: Distribution) ->bool: ... | |
| def__ge__(self, other: Distribution) ->bool: ... | |
| def__eq__(self, other: object) ->bool: ... | |
| def__ne__(self, other: object) ->bool: ... |
| @classmethod | ||
| def from_filename(cls, filename: str, metadata: _MetadataType = None, **kw: str | None | int) -> Distribution: ... | ||
| def activate(self, path: list[str] | None = None) -> None: ... | ||
| def activate(self, path: list[str] | None = None, replace=False) -> None: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| defactivate(self, path: list[str] |None=None, replace=False) ->None: ... | |
| defactivate(self, path: list[str] |None=None, replace: bool=False) ->None: ... |
| class IResourceManager: | ||
| @type_check_only | ||
| class IResourceManager(Protocol): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this class doesn't exist at runtime, should it maybe be private?
| classIResourceManager(Protocol): | |
| class_IResourceManager(Protocol): |
AvasamApr 28, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't that what @type_check_only is for? Granted support is still limited in mypy (python/mypy#15146, python/mypy#9531)
The source docstrings do call it IResourceManager, so it's the right name, makes it easier to find and import, whilst being safer with checkers that support the annotation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, mypy has been pretty slow to implement this feature :)
Elsewhere in typeshed, though, we generally don't rely on a feature unless it's supported by all major type checkers. We use @type_check_only in a few places already, but those are basically all very special cases (builtins.pyi, typing.pyi) where our standard option of making the name private isn't available.
…ignore-missing-stubs-in-setuptools
This comment has been minimized.
This comment has been minimized.
Avasam commented Apr 29, 2023
Oh neat, you can request review from more than one person now on GitHub. |
This comment has been minimized.
This comment has been minimized.
Avasam commented Apr 29, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Pretty sure pyright is failing here because |
AlexWaygood commented May 1, 2023
Seems your diagnosis was spot on! |
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. 🤖🎉 |
JelleZijlstra commented May 19, 2023
Looks good, @AlexWaygood any further feedback? @Avasam feel free to mark conversations as "resolved" if you have addressed them. |
AlexWaygood left a comment • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't reviewed in depth, but all my previous points have been addressed, nothing stands out as weird from a skim-read, and I trust @JelleZijlstra to do a thorough review :)
AlexWaygood left a comment • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't reviewed in depth, but all my previous points have been addressed, nothing stands out as weird from a skim-read, and I trust @JelleZijlstra to do a thorough review :)
#10057 (comment)
ignore_missing_stub = true__all__