Skip to content

Commit 512268b

Browse files
committed
tests
1 parent fb89910 commit 512268b

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

mypy/checker.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,10 +1269,12 @@ def check_default_args(self, item: FuncItem, body_is_trivial: bool) -> None:
12691269
):
12701270
notes = [
12711271
"PEP 484 prohibits implicit Optional. "
1272-
"Accordingly, mypy has changed its default to no_implicit_optional=True.",
1272+
"Accordingly, mypy has changed its default to no_implicit_optional=True",
12731273
"Use https://github.com/hauntsaninja/no_implicit_optional to automatically "
12741274
"upgrade your codebase"
12751275
]
1276+
else:
1277+
notes = None
12761278
self.check_simple_assignment(
12771279
arg.variable.type,
12781280
arg.initializer,

test-data/unit/check-optional.test

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ f(None)
136136

137137
[case testNoInferOptionalFromDefaultNone]
138138
# flags: --no-implicit-optional
139-
def f(x: int = None) -> None: # E: Incompatible default for argument "x" (default has type "None", argument has type "int")
139+
def f(x: int = None) -> None: # E: Incompatible default for argument "x" (default has type "None", argument has type "int") \
140+
# N: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True \
141+
# N: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
140142
pass
141143
[out]
142144

@@ -151,7 +153,9 @@ f(None)
151153

152154
[case testNoInferOptionalFromDefaultNoneComment]
153155
# flags: --no-implicit-optional
154-
def f(x=None): # E: Incompatible default for argument "x" (default has type "None", argument has type "int")
156+
def f(x=None): # E: Incompatible default for argument "x" (default has type "None", argument has type "int") \
157+
# N: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True \
158+
# N: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
155159
# type: (int) -> None
156160
pass
157161
[out]

0 commit comments

Comments
 (0)