| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Here's a slightly evil corner case that this patch doesn't account for: If I have a module typing_test.py, like so: # typing_test.py
class A:
class AA:
foo: intThen, observe the following behaviour (with your patch applied): >>> from typing import get_type_hints, no_type_check
>>> import typing_test
>>> get_type_hints(typing_test.A.AA)
{'foo': <class 'int'>}
>>> @no_type_check
... class A:
... AA = typing_test.A.AA
...
...
>>> get_type_hints(typing_test.A.AA)
{}We might be able to get around this by looking at the __module__ attribute. |
Sorry, something went wrong.
|
@AlexWaygood good one! Very evil! I've addressed this. @JelleZijlstra I agree that we should also fix classmethod / staticmethod problem. Because we declare to support all methods, not just instance methods. The problem is that types.MethodType does not support attribute assignment: >>> class Some:
... @staticmethod
... def st(x: int) -> int: ...
... @classmethod
... def cl(cls, y: int) -> int: ...
>>> Some.st.__no_type_check__ = True
>>> Some.cl.__no_type_check__ = True
AttributeError: 'method' object has no attribute '__no_type_check__'Ideas? Moreover, do we need some special @property support? |
Sorry, something went wrong.
Doesn't look like you've pushed anything -- did you mean to? :) |
Sorry, something went wrong.
Not yet, I am still fighting classmethod 🙂 |
Sorry, something went wrong.
|
Probably if isinstance(obj, types.MethodType):
obj.__func__.__no_type_check__ = Trueis the way to go 🤔 Will write some more tests to be sure. |
Sorry, something went wrong.
There was a problem hiding this comment.
Looks good.
Do you think this should be backported? I'm leaning no as it's a behavior change and nobody directly complained about the old behavior (looks like you found it while reviewing typing test coverage).
Sorry, something went wrong.
There was a problem hiding this comment.
Agreed, a backport doesn't seem asked for.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
There are several changes:
Are there any other cases we want to cover?
https://bugs.python.org/issue46571