-
Notifications
You must be signed in to change notification settings - Fork 263
Make get_type_hints not throw an error on builtin methods #368
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
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 |
src/typing.py
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.