Thanks to visit codestin.com
Credit goes to github.com

Skip to content

bpo-44799: Fix InitVar resolving using get_type_hints #27553

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

Closed
wants to merge 1 commit into from

Conversation

uriyyo
Copy link
Member

@uriyyo uriyyo commented Aug 2, 2021

@@ -228,6 +228,9 @@ class InitVar:
def __init__(self, type):
self.type = type

def __call__(self, *args, **kwargs): # required by typing.get_type_hints, see bpo-44799
Copy link
Member

Choose a reason for hiding this comment

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

How does this solve the problem at hand?

I'm unlikely to accept any changes to dataclasses and typing until PEP 649 is ruled on.

Copy link
Member Author

Choose a reason for hiding this comment

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

Exception raised by _type_check. In case if object is callable this object won't raise exception.

cpython/Lib/typing.py

Lines 180 to 181 in e06ae75

if not callable(arg):
raise TypeError(f"{msg} Got {arg!r:.100}.")

I found that it was the easiest way to solve this issue. If you think it's a bad solution I am open to fix it in another way.

Copy link
Member

Choose a reason for hiding this comment

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

It just seems like it's papering over some actual problem.

In any event, I'm waiting on PEP 649, which if accepted makes this whole point moot.

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense, will wait on a update regarding PEP 649.

@github-actions
Copy link

github-actions bot commented Sep 2, 2021

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Sep 2, 2021
@JelleZijlstra
Copy link
Member

JelleZijlstra commented Mar 12, 2022

Thanks for your contribution! bpo-46644 fixed this issue for 3.11, and we decided not to fix it in 3.9 or 3.10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review stale Stale PR or inactive for long period of time.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants