-
Notifications
You must be signed in to change notification settings - Fork 17
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
Allow types-foo to depend on foo #159
Conversation
I don't think type checkers will resolve this correctly. |
Why do you think that? From type-checkers' PoV, setuptools and pkg_resources are two different packages. And all tests in python/typeshed#13369 (where setuptools needs pkg_resources) pass. Test file: from setuptools import setup
import pkg_resources
from typing_extensions import reveal_type
reveal_type(pkg_resources.Requirement)
setup() w/o
with
with
|
…ader into Allow-self-dependency
stub_uploader/metadata.py
Outdated
if ( | ||
runtime_req_name != upstream_distribution # Allow `types-foo` to require `foo` | ||
and not runtime_in_upstream_requires(req, data) | ||
and not runtime_in_upstream_sdist_requires(req, data) | ||
): |
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.
Alternative syntax:
if ( | |
runtime_req_name != upstream_distribution # Allow `types-foo` to require `foo` | |
and not runtime_in_upstream_requires(req, data) | |
and not runtime_in_upstream_sdist_requires(req, data) | |
): | |
if not ( | |
runtime_req_name == upstream_distribution # Allow `types-foo` to require `foo` | |
or runtime_in_upstream_requires(req, data) | |
or runtime_in_upstream_sdist_requires(req, data) | |
): |
stub_uploader/metadata.py
Outdated
req, data | ||
) and not runtime_in_upstream_sdist_requires(req, data): | ||
if ( | ||
runtime_req_name != upstream_distribution # Allow `types-foo` to require `foo` |
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 you want me to hide this check behind a function for consistency, I'd call it runtime_is_upstream
.
stub_uploader/metadata.py
Outdated
req, data | ||
) and not runtime_in_upstream_sdist_requires(req, data): | ||
if ( | ||
runtime_req_name != upstream_distribution # Allow `types-foo` to require `foo` |
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 think this is the bug that I alluded to when I wrote the refactoring PR. But wouldn't it be clearer to just check req.name == upstream_distribution
at the beginning of the function and exit early? This would also skip fetching the data from PyPI.
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.
But wouldn't it be clearer to just check
req.name == upstream_distribution
at the beginning of the function and exit early? This would also skip fetching the data from PyPI.
If we don't mind not validating that upstream_distribution
does exist on pypi in this case.
Of course for any existing stubs on typeshed we'd assume that its upstream does exist on pypi.
But let's say someone adds a new stubs, mistyped the distribution's name, and makes it reference on itself. It's quite the edge case, but to be considered.
Hmm, I guess stubtest and maybe other tools as well would fail. So probably fine.
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 think this is the bug that I alluded to when I wrote the refactoring PR. But wouldn't it be clearer to just check
req.name == upstream_distribution
I'm not sure which side the the EXTERNAL_RUNTIME_REQ_MAP
makes sense here. (and tbh I may be too tired rn to make sense of it ^^") But I was reusing what's in runtime_in_upstream_sdist_requires
and runtime_in_upstream_requires
Edit: I think it doesn't really matter because we wouldn't self reference, let's say django-stubs
, and this mapping specifically lists stubs outside typeshed. So yeah, simpler to use req.name
directly.
This is relevant
setuptools
in python/typeshed#13369 (comment) and might be relevant topywin32
later as well.Relates to #90