Skip to content

reportUndefinedVariable is a sub category of reportGeneralTypingIssues. #3229

@Gobot1234

Description

@Gobot1234

Describe the bug
After updating some of my code with unsafe casts to the type checker with the new support for # type: ignore comments on a per-line basis #3143, I noticed that on lines with NameErrors reportGeneralTypingIssues was supressing any NameErrors I had on the line.

To Reproduce

NameErrorPlease
NameErrorPlease  # type: ignore
NameErrorPlease  # type: ignore[reportGeneralTypingIssues]
NameErrorPlease  # type: ignore[reportUndefinedVariable]
$ pyright test.py        
No configuration file found.
pyproject.toml file found at /Users/James/PycharmProjects/steam.py.
Loading pyproject.toml file at /Users/James/PycharmProjects/steam.py/pyproject.toml
Assuming Python version 3.10
Assuming Python platform Darwin
Auto-excluding **/node_modules
Auto-excluding **/__pycache__
Auto-excluding **/.*
venvPath not specified, so venv settings will be ignored.
stubPath /Users/James/PycharmProjects/steam.py/typings is not a valid directory.
Searching for source files
Found 1 source file
/Users/James/PycharmProjects/steam.py/test.py
  /Users/James/PycharmProjects/steam.py/test.py:1:1 - error: "NameErrorPlease" is not defined (reportUndefinedVariable)
1 error, 0 warnings, 0 informations 
Completed in 2.92sec

Expected behavior
The first # type: ignore comment should supress the NameError, the second should not and the third should.

VS Code extension or command-line
pyright --version
pyright 1.1.231

Metadata

Metadata

Assignees

No one assigned

    Labels

    as designedNot a bug, working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions