From 97c6873e1a272ce7b38c77af59538d59adb02fb3 Mon Sep 17 00:00:00 2001 From: AlexWaygood Date: Mon, 10 Apr 2023 12:33:49 +0100 Subject: [PATCH] Improve flake8 config --- .flake8 | 1 + .flake8-tests | 1 + src/test_typing_extensions.py | 6 +++--- src/typing_extensions.py | 8 ++++---- test-requirements.txt | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.flake8 b/.flake8 index fc71a6e2..1d2ae2b6 100644 --- a/.flake8 +++ b/.flake8 @@ -13,3 +13,4 @@ exclude = # tests have more relaxed formatting rules # and its own specific config in .flake8-tests src/test_typing_extensions.py, +noqa_require_code = true diff --git a/.flake8-tests b/.flake8-tests index 5a97fe89..db99f22a 100644 --- a/.flake8-tests +++ b/.flake8-tests @@ -26,3 +26,4 @@ ignore = DW12, # consistency with mypy W504 +noqa_require_code = true diff --git a/src/test_typing_extensions.py b/src/test_typing_extensions.py index 21630ad0..1183eaba 100644 --- a/src/test_typing_extensions.py +++ b/src/test_typing_extensions.py @@ -582,7 +582,7 @@ def test_no_isinstance(self): class IntVarTests(BaseTestCase): def test_valid(self): - T_ints = IntVar("T_ints") # noqa + T_ints = IntVar("T_ints") def test_invalid(self): with self.assertRaises(TypeError): @@ -590,7 +590,7 @@ def test_invalid(self): with self.assertRaises(TypeError): T_ints = IntVar("T_ints", bound=int) with self.assertRaises(TypeError): - T_ints = IntVar("T_ints", covariant=True) # noqa + T_ints = IntVar("T_ints", covariant=True) class LiteralTests(BaseTestCase): @@ -936,7 +936,7 @@ def test_respect_no_type_check(self): @no_type_check class NoTpCheck: class Inn: - def __init__(self, x: 'not a type'): ... # noqa + def __init__(self, x: 'not a type'): ... self.assertTrue(NoTpCheck.__no_type_check__) self.assertTrue(NoTpCheck.Inn.__init__.__no_type_check__) self.assertEqual(gth(ann_module2.NTC.meth), {}) diff --git a/src/typing_extensions.py b/src/typing_extensions.py index e39057ac..9ef87b97 100644 --- a/src/typing_extensions.py +++ b/src/typing_extensions.py @@ -289,7 +289,7 @@ def __getitem__(self, parameters): instead of a type.""") -_overload_dummy = typing._overload_dummy # noqa +_overload_dummy = typing._overload_dummy if hasattr(typing, "get_overloads"): # 3.11+ @@ -478,7 +478,7 @@ def _no_init(self, *args, **kwargs): if type(self)._is_protocol: raise TypeError('Protocols cannot be instantiated') - class _ProtocolMeta(abc.ABCMeta): # noqa: B024 + class _ProtocolMeta(abc.ABCMeta): # This metaclass is a bit unfortunate and exists only because of the lack # of __instancehook__. def __instancecheck__(cls, instance): @@ -545,7 +545,7 @@ def __class_getitem__(cls, params): raise TypeError( f"Parameter list to {cls.__qualname__}[...] cannot be empty") msg = "Parameters to generic types must be types." - params = tuple(typing._type_check(p, msg) for p in params) # noqa + params = tuple(typing._type_check(p, msg) for p in params) if cls is Protocol: # Generic can only be subscripted with unique type variables. if not all(isinstance(p, typing.TypeVar) for p in params): @@ -1435,7 +1435,7 @@ def _concatenate_getitem(self, parameters): # 3.10+ if hasattr(typing, 'Concatenate'): Concatenate = typing.Concatenate - _ConcatenateGenericAlias = typing._ConcatenateGenericAlias # noqa + _ConcatenateGenericAlias = typing._ConcatenateGenericAlias # noqa: F811 # 3.9 elif sys.version_info[:2] >= (3, 9): @_TypeAliasForm diff --git a/test-requirements.txt b/test-requirements.txt index 05c4c918..ad5c3e58 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,3 +1,3 @@ flake8 flake8-bugbear -flake8-pyi>=22.8.0 +flake8-noqa