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

Add better default value for TypeVar default (PEP 696) #85

Merged
merged 1 commit into from
Oct 27, 2022
Merged

Add better default value for TypeVar default (PEP 696) #85

merged 1 commit into from
Oct 27, 2022

Conversation

cdce8p
Copy link
Contributor

@cdce8p cdce8p commented Oct 7, 2022

Ref: #77 (comment)

/CC: @Gobot1234 @JelleZijlstra
This is a solution. Let me know if you had something different in mind.

@Gobot1234
Copy link
Contributor

Should the default be not be public to allow people to check if a default wasn't passed?

@cdce8p
Copy link
Contributor Author

cdce8p commented Oct 7, 2022

Should the default be not be public to allow people to check if a default wasn't passed?

That was my first idea. However, it's not actually necessary. Take a look at _DefaultMixin. We pass all inputs (expect our own default) to typing._type_check which itself calls _type_convert. If None is passed, the value stored in self.__default__ will be type(None), for everything else it's just the arg itself. So unless I'm missing something, it should already work.

https://github.com/python/cpython/blob/v3.11.0rc2/Lib/typing.py#L159-L165

@@ -1,3 +1,8 @@
# Release 4.4.1 (?)
Copy link
Member

Choose a reason for hiding this comment

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

Might end up being 4.5.0, but we can change that later.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We should probably just use UNRELEASED in the future.

@JelleZijlstra JelleZijlstra merged commit 0dc7304 into python:main Oct 27, 2022
@cdce8p cdce8p deleted the pep696-default-none branch October 27, 2022 06:06
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.

None yet

4 participants