-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
C: used-before-assignmentIssues related to 'used-before-assignment' checkIssues related to 'used-before-assignment' checkFalse Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementation
Milestone
Description
Bug description
When allow-global-unused-variables
is set to false
in the configuration, the unused-variable
warning is raised for imports made under TYPE_CHECKING
guard clauses. This behavior seems inconsistent with unused-import
, which is not raised for such cases.
# test.py
# pylint: disable=missing-module-docstring
from typing import TYPE_CHECKING
if TYPE_CHECKING:
import math # [unused-variable]
Configuration
[tool.pylint.variables]
allow-global-unused-variables=false
Command used
pylint test.py
Pylint output
************* Module test
test.py:6:4: W0612: Unused variable 'math' (unused-variable)
Expected behavior
No warnings raised.
Pylint version
pylint 3.0.0b1
astroid 3.0.0a2
Python 3.8.10 (default, Nov 14 2022, 12:59:47)
[GCC 9.4.0]
OS / Environment
WSL2 Ubuntu 20.04 LTS
Additional dependencies
No response
jacobtylerwalls
Metadata
Metadata
Assignees
Labels
C: used-before-assignmentIssues related to 'used-before-assignment' checkIssues related to 'used-before-assignment' checkFalse Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementation