Skip to content

Conversation

msullivan
Copy link
Collaborator

  • Fix --no-any to not spuriously reject all methods
  • Support inferring types of decorated methods if the decorator
    doesn't change the type
  • Refuse to infer functions with then or more arguments to avoid
    spending forever calculating an exponentially large number of
    possibilities before deciding there are too many possibilities.

I've already successfully used this code in generating annotations at Dropbox.

 * Fix --no-any to not spuriously reject all methods
 * Support inferring types of decorated methods if the decorator
   doesn't change the type
 * Refuse to infer functions with then or more arguments to avoid
   spending forever calculating an exponentially large number of
   possibilities before deciding there are too many possibilities.
@msullivan msullivan requested review from JukkaL and gvanrossum June 14, 2019 18:54
Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement! Note you have a leftover debug print.

if not isinstance(node, FuncDef):
raise SuggestionFailure("Object %s is not a function" % key)

return (modname, tail, node)

def extract_from_decorator(self, node: Decorator) -> Optional[FuncDef]:
for dec in node.decorators:
print(dec)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug print.

@msullivan msullivan merged commit 5fdb16b into master Jun 17, 2019
@msullivan msullivan deleted the suggestion-fixes branch June 17, 2019 23:35
PattenR pushed a commit to PattenR/mypy that referenced this pull request Jun 23, 2019
 * Fix --no-any to not spuriously reject all methods
 * Support inferring types of decorated methods if the decorator
   doesn't change the type
 * Refuse to infer functions with then or more arguments to avoid
   spending forever calculating an exponentially large number of
   possibilities before deciding there are too many possibilities.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants