@@ -1262,13 +1262,25 @@ def check_default_args(self, item: FuncItem, body_is_trivial: bool) -> None:
1262
1262
msg += f"tuple argument { name [12 :]} "
1263
1263
else :
1264
1264
msg += f'argument "{ name } "'
1265
+ if (
1266
+ not self .options .implicit_optional
1267
+ and isinstance (arg .initializer , NameExpr )
1268
+ and arg .initializer .fullname == "builtins.None"
1269
+ ):
1270
+ notes = [
1271
+ "PEP 484 prohibits implicit Optional. "
1272
+ "Accordingly, mypy has changed its default to no_implicit_optional=True." ,
1273
+ "Use https://github.com/hauntsaninja/no_implicit_optional to automatically "
1274
+ "upgrade your codebase"
1275
+ ]
1265
1276
self .check_simple_assignment (
1266
1277
arg .variable .type ,
1267
1278
arg .initializer ,
1268
1279
context = arg .initializer ,
1269
1280
msg = ErrorMessage (msg , code = codes .ASSIGNMENT ),
1270
1281
lvalue_name = "argument" ,
1271
1282
rvalue_name = "default" ,
1283
+ notes = notes ,
1272
1284
)
1273
1285
1274
1286
def is_forward_op_method (self , method_name : str ) -> bool :
@@ -3739,6 +3751,8 @@ def check_simple_assignment(
3739
3751
msg : ErrorMessage = message_registry .INCOMPATIBLE_TYPES_IN_ASSIGNMENT ,
3740
3752
lvalue_name : str = "variable" ,
3741
3753
rvalue_name : str = "expression" ,
3754
+ * ,
3755
+ notes : list [str ] | None = None ,
3742
3756
) -> Type :
3743
3757
if self .is_stub and isinstance (rvalue , EllipsisExpr ):
3744
3758
# '...' is always a valid initializer in a stub.
@@ -3763,6 +3777,7 @@ def check_simple_assignment(
3763
3777
msg ,
3764
3778
f"{ rvalue_name } has type" ,
3765
3779
f"{ lvalue_name } has type" ,
3780
+ notes = notes ,
3766
3781
)
3767
3782
return rvalue_type
3768
3783
@@ -5666,6 +5681,7 @@ def check_subtype(
5666
5681
subtype_label : str | None = None ,
5667
5682
supertype_label : str | None = None ,
5668
5683
* ,
5684
+ notes : list [str ] | None = None ,
5669
5685
code : ErrorCode | None = None ,
5670
5686
outer_context : Context | None = None ,
5671
5687
) -> bool :
@@ -5681,6 +5697,7 @@ def check_subtype(
5681
5697
subtype_label : str | None = None ,
5682
5698
supertype_label : str | None = None ,
5683
5699
* ,
5700
+ notes : list [str ] | None = None ,
5684
5701
outer_context : Context | None = None ,
5685
5702
) -> bool :
5686
5703
...
@@ -5694,6 +5711,7 @@ def check_subtype(
5694
5711
subtype_label : str | None = None ,
5695
5712
supertype_label : str | None = None ,
5696
5713
* ,
5714
+ notes : list [str ] | None = None ,
5697
5715
code : ErrorCode | None = None ,
5698
5716
outer_context : Context | None = None ,
5699
5717
) -> bool :
@@ -5714,7 +5732,7 @@ def check_subtype(
5714
5732
return False
5715
5733
extra_info : list [str ] = []
5716
5734
note_msg = ""
5717
- notes : list [ str ] = []
5735
+ notes = notes or []
5718
5736
if subtype_label is not None or supertype_label is not None :
5719
5737
subtype_str , supertype_str = format_type_distinctly (orig_subtype , orig_supertype )
5720
5738
if subtype_label is not None :
@@ -5725,7 +5743,7 @@ def check_subtype(
5725
5743
outer_context or context , subtype , supertype , supertype_str
5726
5744
)
5727
5745
if isinstance (subtype , Instance ) and isinstance (supertype , Instance ):
5728
- notes = append_invariance_notes ([] , subtype , supertype )
5746
+ notes = append_invariance_notes (notes , subtype , supertype )
5729
5747
if extra_info :
5730
5748
msg = msg .with_additional_msg (" (" + ", " .join (extra_info ) + ")" )
5731
5749
0 commit comments