forked from pylint-dev/pylint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't emit 'unused-variable' or 'unused-import' on names in string li…
…teral type annotations (pylint-dev#3299)
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
tests/functional/u/unused/unused_name_in_string_literal_type_annotation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"""Test if pylint sees names inside string literal type annotations. #3299""" | ||
from argparse import ArgumentParser, Namespace | ||
from pathlib import Path | ||
from typing import TypeAlias | ||
|
||
def unused_variable_should_not_be_emitted(): | ||
"""unused-variable shouldn't be emitted for Example1.""" | ||
Example1: TypeAlias = int | ||
result: set["Example1"] = set() | ||
return result | ||
|
||
# unused-import shouldn't be emitted for Path | ||
example2: set["Path"] = set() | ||
|
||
def example3(_: "ArgumentParser"): | ||
"""unused-import shouldn't be emitted for ArgumentParser""" | ||
|
||
# pylint: disable=too-few-public-methods | ||
class Class: | ||
"""unused-import shouldn't be emitted for Namespace""" | ||
cls: "Namespace" |