-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
bugmypy got something wrongmypy got something wrongneeds discussionpriority-0-hightopic-overloadstopic-pluginsThe plugin API and ideas for new pluginsThe plugin API and ideas for new plugins
Description
While working on our own plugin for self-checking proper types and isinstance() I have tried to use get_function_hook() to emit some additional errors for overloaded functions. However this didn't work for three reasons:
- The hook is called for every item in the overload, not for the overload as a whole.
- The overload logic relies on empty
Messagesas a sign of successful match - The errors emitted during overload selection are discarded afterwards, thus discarding the plugin generated errors
This issue can be fixed in three ways:
- Calling the hook on the overload as a whole after selecting the overload variant and type checking it (this however will be a breaking API change)
- Use newly added error codes to only abandon a variant if the error is due to bad argument type (this is however still bad because
check_call()may have anaccept()call possibly triggering almost arbitrary error including a nested function call with bad argument type). - Use a boolean attribute somewhere that will be set by
check_argument_types()and will be reset after return from everyaccept().
I am leaning towards the last option, since it is most principled IMO.
cc @Michael0x2a
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongneeds discussionpriority-0-hightopic-overloadstopic-pluginsThe plugin API and ideas for new pluginsThe plugin API and ideas for new plugins