-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
Description
A globally defined type variable, usually a short-hand, is reported as being an unused global variable py/unused-global-variable, when it reality it's not, because it's used in a string type annotation.
Our code is closed source, so unfortunately a made up example will have illustrate the false positive:
from typing import TYPE_CHECKING
if TYPE_CHECKING:
JiraIssue = dict[str, str]
def titlecase_jira_issues(issues: list['JiraIssue']):
for issue in issues:
issue['title'] = issue['title'].title()In the snippet above, JiraIssue is reported as unused. We're using the codeql-bundle-v2.20.5/codeql-bundle-linux64.tar.zst.
The closest related issue I could find deals with a similar case involving unused imports, see #2042.