mypy
mypy copied to clipboard
Used before def false positive when aliasing builtin definition
The first error is a false positive, since range is available in builtins:
_range = range # error: Name "range" is used before definition
_C = C # error: Name "C" is used before definition
class range:
pass
class C:
pass
This is not reported consistently. In this case there is no error:
_range = range # No error!
class range:
pass
I assume the error is only generated when we perform two or more semantic analysis passes.
This is a regression introduced in #14166.