Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Improve handling of constraints on requirements with extras #12095
Improve handling of constraints on requirements with extras #12095
Changes from 17 commits
5bebe85
937d8f0
5f8f40e
d09431f
49027d7
cb0f97f
3160293
1038f15
8aa1758
faa3289
7e8da61
ff9aeae
3fa373c
e569017
cc6a2bd
fc86308
4ae829c
dc01a40
292387f
39e1102
e6333bb
1207389
6663b89
314d7c1
cc909e8
6ed231a
55e9762
504485c
f4a7c0c
32e95be
ba761cd
3f3ae6f
21bfe40
0de374e
5a01679
9041602
4e73e3e
50cd318
ff9e15d
f5602fa
449522a
952ab6d
fbda0a2
ce94946
46707a4
89b68c6
0f543e3
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Would be good to provide a message here (and the assert just below) in case this ever appears in an error report.
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'm not sure how verbose it should be or what exactly to report on but I made an attempt at a message.
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.
Interestingly, Mypy (typeshed, technically) does not mark the return value of
group
as Optional, despite the documentation clears says None is a possible return value, so this would just work. I’m not totally sure if we should rely on this though.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.
Looks like typeshed has a union with
Any
in the return type for this method: https://github.com/python/typeshed/blob/fecb84eb058833ea20c83162fa9dd4421e23f127/stdlib/re.pyi#L77C61-L77C61. Indeed,reveal_type
showsUnion[str, Any]
. This explains whystr
is accepted, and I'm therefore inclined to leave this part as is.Interestingly (though largely beside the point), the following is not accepted by mypy. I would have expected the
Any
as part of the union to allow for any annotation.EDIT: figured it out, not so strange after all.
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 found some context on the motivation for the Any union. I see why they couldn't make the change, but I still feel like clients of the library should ideally make an effort to use the correct type, even where typeshed is too permissive by necessity. Let me know if you think differently.
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 feel maybe we should remove the None case and make this always an ireq instance (i.e. if we didn’t do extra manipulation this would just be
base.ireq
) to avoid an unnecessary branching.It might be useful for this argument (and attribute) to have a different name to indicate it’s only for reporting.
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.
Fine by me. I personally prefer to be explicit when reverting to defaults but it's a thin line in this case.
I moved it up so that the attribute is not optional (50cd318), but I think it would be cleaner to leave the constructor argument optional for two reasons:
_ireq
is a "private" attribute onBaseCandidate
. Accessing it from within the same module is one thing, doing so fromfactory
feels to me like a violation of the interface. We could of course rename the attribute if we want.With this context, how would you like me to proceed?