From 9ed47fa8ece45ff7fa17e30cd439be4ae1f5c3a5 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Thu, 24 Oct 2024 14:26:37 +0100 Subject: [PATCH] Fix linting issues (#12898) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- stdlib/@tests/test_cases/check_os_path.py | 3 ++- stdlib/ast.pyi | 1 - stdlib/warnings.pyi | 2 +- stubs/netifaces/netifaces.pyi | 2 +- .../test_cases/check_nested_descriptors.py | 16 ++++------------ 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/stdlib/@tests/test_cases/check_os_path.py b/stdlib/@tests/test_cases/check_os_path.py index aeec873fb..bd6911ed3 100644 --- a/stdlib/@tests/test_cases/check_os_path.py +++ b/stdlib/@tests/test_cases/check_os_path.py @@ -1,9 +1,10 @@ from __future__ import annotations + from _typeshed import StrOrBytesPath from os import PathLike from os.path import abspath, expanduser, expandvars -from typing_extensions import assert_type from typing import AnyStr, Union +from typing_extensions import assert_type def test_str_path(str_path: StrOrBytesPath) -> None: diff --git a/stdlib/ast.pyi b/stdlib/ast.pyi index e6be9038b..351a4af2f 100644 --- a/stdlib/ast.pyi +++ b/stdlib/ast.pyi @@ -2036,7 +2036,6 @@ class NodeVisitor: @deprecated("Replaced by visit_Constant; removed in Python 3.14") def visit_Ellipsis(self, node: Ellipsis) -> Any: ... # type: ignore[deprecated] - class NodeTransformer(NodeVisitor): def generic_visit(self, node: AST) -> AST: ... # TODO: Override the visit_* methods with better return types. diff --git a/stdlib/warnings.pyi b/stdlib/warnings.pyi index fa37018b5..533a36817 100644 --- a/stdlib/warnings.pyi +++ b/stdlib/warnings.pyi @@ -1,5 +1,5 @@ -import sys import re +import sys from _warnings import warn as warn, warn_explicit as warn_explicit from collections.abc import Sequence from types import ModuleType, TracebackType diff --git a/stubs/netifaces/netifaces.pyi b/stubs/netifaces/netifaces.pyi index 104ab384e..fa146c357 100644 --- a/stubs/netifaces/netifaces.pyi +++ b/stubs/netifaces/netifaces.pyi @@ -1,4 +1,4 @@ -from typing import Literal, Final +from typing import Final, Literal AF_12844: Final[int] AF_APPLETALK: Final[int] diff --git a/stubs/openpyxl/@tests/test_cases/check_nested_descriptors.py b/stubs/openpyxl/@tests/test_cases/check_nested_descriptors.py index 301d519f0..e28920ed8 100644 --- a/stubs/openpyxl/@tests/test_cases/check_nested_descriptors.py +++ b/stubs/openpyxl/@tests/test_cases/check_nested_descriptors.py @@ -304,15 +304,9 @@ with_descriptors.text_int_not_none = "0" with_descriptors.text_int_not_none = None # type: ignore with_descriptors.text_int_not_none = object() # type: ignore # If expected type (_T) is not str, it's impossible to use an Element as the value -with_descriptors.text_int_not_none = cast( # type: ignore - _HasTagAndGet[int], _ -) -with_descriptors.text_int_not_none = cast( # type: ignore - _HasTagAndGet[None], _ -) -with_descriptors.text_int_not_none = cast( # type: ignore - _HasTagAndGet[str], _ -) +with_descriptors.text_int_not_none = cast(_HasTagAndGet[int], _) # type: ignore +with_descriptors.text_int_not_none = cast(_HasTagAndGet[None], _) # type: ignore +with_descriptors.text_int_not_none = cast(_HasTagAndGet[str], _) # type: ignore with_descriptors.text_int_none = 0 with_descriptors.text_int_none = "0" @@ -336,9 +330,7 @@ with_descriptors.minmax_float = 0.0 with_descriptors.minmax_float = None # type: ignore with_descriptors.minmax_float = object() # type: ignore with_descriptors.minmax_float = cast(_HasTagAndGet[float], _) -with_descriptors.minmax_float = cast( # type: ignore - _HasTagAndGet[None], _ -) +with_descriptors.minmax_float = cast(_HasTagAndGet[None], _) # type: ignore with_descriptors.minmax_float = cast(_HasTagAndGet[object], _) # type: ignore with_descriptors.minmax_float_none = 0