bpo-44799: Fix InitVar resolving using get_type_hints by uriyyo · Pull Request #27553 · python/cpython
| def __init__(self, type): | ||
| self.type = type | ||
|
|
||
| def __call__(self, *args, **kwargs): # required by typing.get_type_hints, see bpo-44799 |
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.
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.
| 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.
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.
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.