Skip to content

Used before def false positive when aliasing builtin definition #14476

Closed

Description

@JukkaL

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.

Activity

  1. added a commit that references this issue on Jan 24, 2023
    8b30913
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongfalse-positivemypy gave an error on correct codetopic-possibly-undefinedpossibly-undefined error code

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions