Skip to content

Commit 385554f

Browse files
committed
Handle adjacent decorated underscore functions in semanal
Instead of turning adjacent decorated underscore functions into a series of FuncDefs instead of one OverloadedFuncDef in the parser, handle OverloadedFuncDefs named '_' in semanal. That prevents us from needing to make that change in fastparse2, and move the handling of the underscore function case closer to where the error would be emitted.
1 parent 36f8bcc commit 385554f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

mypy/fastparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ def fix_function_overloads(self, stmts: List[Statement]) -> List[Statement]:
455455
elif len(current_overload) > 1:
456456
ret.append(OverloadedFuncDef(current_overload))
457457

458-
if isinstance(stmt, Decorator) and stmt.name != "_":
458+
if isinstance(stmt, Decorator):
459459
current_overload = [stmt]
460460
current_overload_name = stmt.name
461461
else:

mypy/semanal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ def handle_missing_overload_decorators(self,
812812
else:
813813
self.fail("The implementation for an overloaded function "
814814
"must come last", defn.items[idx])
815-
else:
815+
elif defn.name != "_":
816816
for idx in non_overload_indexes[1:]:
817817
self.name_already_defined(defn.name, defn.items[idx], defn.items[0])
818818
if defn.impl:

0 commit comments

Comments
 (0)