Skip to content

[ty] lint:unresolved-reference for globals #300

@mitsuhiko

Description

@mitsuhiko

Summary

_foo = False

def stuff():
    global _foo
    if not _foo:
        _foo = True

Gives the following type check warning:

warning: lint:unresolved-reference: Name `_foo` used when not defined
 --> test.py:5:12
  |
3 | def stuff():
4 |     global _foo
5 |     if not _foo:
  |            ^^^^
6 |         _foo = True
  |
info: `lint:unresolved-reference` is enabled by default

Version

ty 0.0.0-alpha.7 (905a3e1 2025-05-07)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions