-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Description
Recently the --warn-return-any option was added which causes mypy to warn if returning a value with an Any type (#2854). @ddfisher pointed out the this is not very general:
Thinking out loud here: this helps catch accidental Anys in one particular circumstance, but it might be nice to have something a bit more comprehensive as well. Perhaps we should consider adding a flag which disallows use of Any-typed values except as the right hand side of an assignment with a type comment (i.e. forcing all Anys to be immediately typed).
I agree that #2854 seems too narrowly focused. I like @ddfisher's suggestion, with a few tweaks:
Anyshould probably be okay as a function argument type if the argument type isAny(orobject).- Assigning an
Anyvalue to a variable with anAny/objecttype seems okay as well. - Narrowing down from an
Anyvalue usingisinstanceorcastshould be allowed.
Herst