You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Behind a config flag like untyped_return_type_is_none = true, Mypy assumes that a function with no return type, e.g.:
defmy_func(i_am_annotated: str): # Note: no "-> int" annotationreturn5
Returns None, instead of accepting any return type at face value.
Additionally, while untyped_return_type_is_none is true, disallow_untyped_defs allows functions to have no return annotation if their return type is None.
Pitch
Adoption for the disallow_untyped_defs is difficult, because it requires None to be explicitly annotated. This makes code more wordy in many places where the annotation adds zero value (think of all test functions/methods for extremely popular frameworks like pytest or unittest). This is especially overwhelming for maintainers of large codebases with many tests and existing functions.
Having the flag would give users an option to leave -> None functions unannotated.
Current behaviour would be unchanged if the new flag were not activated, but activating the flag would force users to annotate those functions that do return a value, providing a large but progressive step towards disallow_untyped_defs, reducing the essentially meaningless menial work of adding -> None everywhere.
The text was updated successfully, but these errors were encountered:
Feature
Behind a config flag like
untyped_return_type_is_none = true
, Mypy assumes that a function with no return type, e.g.:Returns
None
, instead of accepting any return type at face value.Additionally, while
untyped_return_type_is_none
is true,disallow_untyped_defs
allows functions to have no return annotation if their return type isNone
.Pitch
Adoption for the
disallow_untyped_defs
is difficult, because it requiresNone
to be explicitly annotated. This makes code more wordy in many places where the annotation adds zero value (think of all test functions/methods for extremely popular frameworks like pytest or unittest). This is especially overwhelming for maintainers of large codebases with many tests and existing functions.Having the flag would give users an option to leave
-> None
functions unannotated.Current behaviour would be unchanged if the new flag were not activated, but activating the flag would force users to annotate those functions that do return a value, providing a large but progressive step towards
disallow_untyped_defs
, reducing the essentially meaningless menial work of adding-> None
everywhere.The text was updated successfully, but these errors were encountered: