Skip to content

Commit

Permalink
default return: dont suppress unannotated errors
Browse files Browse the repository at this point in the history
  • Loading branch information
KotlinIsland committed Apr 7, 2022
1 parent 61a69cb commit 013311a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,7 @@ def is_unannotated_any(t: Type) -> bool:
typ.ret_type = NoneType()
# fully unannotated fdef needs to be assigned a type
fdef.type = typ
self.check_for_missing_annotations(fdef, typ)
else:
if (not fdef.arguments or (len(fdef.arguments) == 1 and
(fdef.arg_names[0] == 'self' or fdef.arg_names[0] == 'cls'))):
Expand Down
7 changes: 7 additions & 0 deletions test-data/unit/check-based-default-return.test
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ reveal_type(A.f) # N:13: Revealed type is "def (self: __main__.A)"
reveal_type(A.g) # N:13: Revealed type is "def (self: __main__.A, i: builtins.int)"


[case testPartiallyTyped]
# flags: --default-return --allow-any-expr
def foo(a): ... # E:1: Function is missing a type annotation for one or more arguments [no-untyped-def]
reveal_type(foo) # N:13: Revealed type is "def (a: Any)"



[case testUntypedDefs]
# flags: --default-return --allow-untyped-defs --allow-any-expr

Expand Down

0 comments on commit 013311a

Please sign in to comment.