Make get_type_hints not throw an error on builtin methods#368
Conversation
…t__ or object.__str__ etc.
|
Thank you for the PR! |
|
@wheerd After you take a look at my latest review on b.p.o., could you please update this PR using the |
| isinstance(obj, types.ModuleType) | ||
| isinstance(obj, types.ModuleType) or | ||
| isinstance(obj, _wrapper_descriptor_type) or | ||
| isinstance(obj, _method_wrapper_type) |
There was a problem hiding this comment.
I don't like this isinstance chain.
How about this?
# global
_annotatable_types = (
types.FunctionType,
types.BuiltinFunctionType,
types.MethodType,
types.ModuleType,
_wrapper_descriptor_type,
_method_wrapper_type)
...
if isinstance(obj, _annotatable_types):
There was a problem hiding this comment.
Thank, you! I have already noticed this some time ago, I would prefer to fix this separately after this PR is merged.
|
@wheerd Could you please update the PR using the |
…ypes in the types module.
|
Sorry I completely forgot about the pull request. Should be fixed now. |
|
Thanks! |
While builtin functions are supported, calling get_type_hints on a builtin method like
object.__init__causes an error. I change this to return an empty dictionary instead.