Skip to content
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

Remove ParamSpec for SupportsReplace #12410

Merged
merged 6 commits into from
Sep 14, 2024

Conversation

max-muoto
Copy link
Contributor

Address Eric's comment here: #12262 (comment)

Accidentally undid this commit before merging.

This comment has been minimized.

This comment has been minimized.

Comment on lines +10 to +12
class _SupportsReplace(Protocol):
# In reality doesn't support args, but there's no other great way to express this.
def __replace__(self, *args: _P.args, **kwargs: _P.kwargs) -> Self: ...
def __replace__(self, *args: Any, **kwargs: Any) -> Self: ...
Copy link
Collaborator

Choose a reason for hiding this comment

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

(Can't add this as suggestion.)

class _SupportsReplace(Protocol):
    def __replace__(self, **changes: Any) -> Self: ...  # changes as passed to replace()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you look back at the old PR, this doesn't work, since type-checkers will complain if the implementation does have **kwargs, as opposed to supporting any amount of variable key word arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@srittau Just wanted to follow up on this.

This comment has been minimized.

@max-muoto
Copy link
Contributor Author

@srittau Just wanted to follow-up again on this one.

This comment has been minimized.

@max-muoto
Copy link
Contributor Author

@srittau Sorry to double ping here, but was curious if you had any thoughts!

Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau srittau merged commit f190a1f into python:main Sep 14, 2024
63 checks passed
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants