Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypy/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -1992,7 +1992,7 @@ def incorrect__exit__return(self, context: Context) -> None:
code=codes.EXIT_RETURN,
)
self.note(
'Use "typing_extensions.Literal[False]" as the return type or change it to "None"',
'Use "typing.Literal[False]" as the return type or change it to "None"',
context,
code=codes.EXIT_RETURN,
)
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/check-errorcodes.test
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ main:2: error: Syntax error in type comment "int" [syntax]
[case testErrorCode__exit__Return]
class InvalidReturn:
def __exit__(self, x, y, z) -> bool: # E: "bool" is invalid as return type for "__exit__" that always returns False [exit-return] \
# N: Use "typing_extensions.Literal[False]" as the return type or change it to "None" \
# N: Use "typing.Literal[False]" as the return type or change it to "None" \
# N: If return type of "__exit__" implies that it may return True, the context manager may swallow exceptions
return False
[builtins fixtures/bool.pyi]
Expand Down
6 changes: 3 additions & 3 deletions test-data/unit/check-statements.test
Original file line number Diff line number Diff line change
Expand Up @@ -1527,13 +1527,13 @@ from typing import Optional

class InvalidReturn1:
def __exit__(self, x, y, z) -> bool: # E: "bool" is invalid as return type for "__exit__" that always returns False \
# N: Use "typing_extensions.Literal[False]" as the return type or change it to "None" \
# N: Use "typing.Literal[False]" as the return type or change it to "None" \
# N: If return type of "__exit__" implies that it may return True, the context manager may swallow exceptions
return False

class InvalidReturn2:
def __exit__(self, x, y, z) -> Optional[bool]: # E: "bool" is invalid as return type for "__exit__" that always returns False \
# N: Use "typing_extensions.Literal[False]" as the return type or change it to "None" \
# N: Use "typing.Literal[False]" as the return type or change it to "None" \
# N: If return type of "__exit__" implies that it may return True, the context manager may swallow exceptions
if int():
return False
Expand All @@ -1542,7 +1542,7 @@ class InvalidReturn2:

class InvalidReturn3:
def __exit__(self, x, y, z) -> bool: # E: "bool" is invalid as return type for "__exit__" that always returns False \
# N: Use "typing_extensions.Literal[False]" as the return type or change it to "None" \
# N: Use "typing.Literal[False]" as the return type or change it to "None" \
# N: If return type of "__exit__" implies that it may return True, the context manager may swallow exceptions
def nested() -> bool:
return True
Expand Down
Loading