-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Don't ignore missing stubs in setuptools #10058
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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 ...
.
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.
def find_module(module, paths=None) -> tuple[IO[Any], str, tuple[str, Literal["", "r", "rb"], Literal[7, 6, 1, 2, 3, -1]]]: ... | |
def find_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.
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.
def subscribe(self, callback: Callable[[Distribution], object], existing=True) -> None: ... | |
def subscribe(self, callback: Callable[[Distribution], object], existing: bool = True) -> None: ... |
@@ -89,6 +97,7 @@ class Requirement: | |||
# 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: ... |
@@ -164,15 +184,17 @@ class Distribution(NullProvider, IResourceProvider, IMetadataProvider): | |||
) -> Distribution: ... | |||
@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.
def activate(self, path: list[str] | None = None, replace=False) -> None: ... | |
def activate(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?
class IResourceManager(Protocol): | |
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.
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.
Oh neat, you can request review from more than one person now on GitHub. |
This comment has been minimized.
This comment has been minimized.
Pretty sure pyright is failing here because |
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. 🤖🎉 |
Looks good, @AlexWaygood any further feedback? @Avasam feel free to mark conversations as "resolved" if you have addressed them. |
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 :)
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__