Skip to content

Commit 3eef162

Browse files
committed
Add test with imported function being overwritten
Add a test that makes sure that we reject overwriting an imported function that is aliased as _ with an underscore function, as that is probably an error (especially when using _ as an alias for gettext).
1 parent dd6baa3 commit 3eef162

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

test-data/unit/check-redefine.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,3 +559,13 @@ def f(arg):
559559
@dec2
560560
def _(arg):
561561
pass
562+
563+
[case testOverwritingImportedFunctionThatWasAliasedAsUnderscore]
564+
from a import f as _
565+
566+
def _(arg: str) -> str: # E: Name "_" already defined (possibly by an import)
567+
return arg
568+
569+
[file a.py]
570+
def f(s: str) -> str:
571+
return s

0 commit comments

Comments
 (0)