Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-102615: Fix type vars substitution ofcollections.abc.Callable and custom generics withParamSpec#102681

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
sobolevn wants to merge2 commits intopython:mainfromsobolevn:new-expand

Conversation

@sobolevn
Copy link
Member

@sobolevnsobolevn commentedMar 14, 2023
edited by bedevere-bot
Loading

I would prefer to create two PRs tofix#102615

  1. This one that fixes a bug withCallable and custom generics withParamSpec
  2. gh-102615: Uselist instead oftuple inrepr of paramspec #102637 to change therepr

@Fidget-Spinner
Copy link
Member

Fidget-Spinner commentedMar 14, 2023
edited
Loading

I encountered another bug, the__repr__ needs to be updated as well:

>>> ca.Callable[[int, P], int][P][int]collections.abc.Callable[[int, (<class 'int'>,)], int]

EDIT: THIS MIGHT NOT BE A BUG, AS ITS AN INVALID USE. PLEASE IGNORE THIS@sobolevn

@sobolevn
Copy link
MemberAuthor

sobolevn commentedMar 14, 2023
edited
Loading

@Fidget-Spinner I would like to move allrepr related problems to another PR if that possible :)

I've only touched params substitution here.

@sobolevn
Copy link
MemberAuthor

sobolevn commentedMar 14, 2023
edited
Loading

Wait a moment, this is not aboutrepr, this is an__args__ containing atuple 😒

>>>ca.Callable[[int,P],int][P].__args__(<class'int'>,~P,<class'int'>)>>>ca.Callable[[int,P],int][P][int].__args__(<class'int'>, (<class'int'>,),<class'int'>)

@rhettingerrhettinger removed their request for reviewMarch 14, 2023 13:42
@sobolevn
Copy link
MemberAuthor

sobolevn commentedMar 14, 2023
edited
Loading

Funny thing, I just removed this code from_collections_abc.py as an experiment:

if (len(self.__parameters__)==1and_is_param_expr(self.__parameters__[0])anditemandnot_is_param_expr(item[0])):item= (item,)

All tests still pass :)

🤯

Copy link
Member

@AlexWaygoodAlexWaygood left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think the runtime is correct in raising TypeError for these situations, actually: see#102615 (comment)

Maybe instead, we should focus on improving the error message, so that users get more specific feedback on why the substitution is being disallowed? Though if it adds too much complexity to the code, I probably wouldn't bother with it.

@sobolevn
Copy link
MemberAuthor

I am going to close this for now, I will add new tests in other PRs, because this one has a big unrelated history.

AlexWaygood reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@Fidget-SpinnerFidget-SpinnerFidget-Spinner left review comments

@AlexWaygoodAlexWaygoodAlexWaygood left review comments

@gvanrossumgvanrossumAwaiting requested review from gvanrossum

@JelleZijlstraJelleZijlstraAwaiting requested review from JelleZijlstraJelleZijlstra is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Representation of ParamSpecs at runtime compared to Callable

4 participants

@sobolevn@Fidget-Spinner@AlexWaygood@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp