Skip to content

Commit ad8a08b

Browse files
authored
Improve flake8 config (#133)
1 parent 6db3067 commit ad8a08b

5 files changed

+10
-8
lines changed

.flake8

+1
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ exclude =
1313
# tests have more relaxed formatting rules
1414
# and its own specific config in .flake8-tests
1515
src/test_typing_extensions.py,
16+
noqa_require_code = true

.flake8-tests

+1
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ ignore =
2626
DW12,
2727
# consistency with mypy
2828
W504
29+
noqa_require_code = true

src/test_typing_extensions.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -582,15 +582,15 @@ def test_no_isinstance(self):
582582

583583
class IntVarTests(BaseTestCase):
584584
def test_valid(self):
585-
T_ints = IntVar("T_ints") # noqa
585+
T_ints = IntVar("T_ints")
586586

587587
def test_invalid(self):
588588
with self.assertRaises(TypeError):
589589
T_ints = IntVar("T_ints", int)
590590
with self.assertRaises(TypeError):
591591
T_ints = IntVar("T_ints", bound=int)
592592
with self.assertRaises(TypeError):
593-
T_ints = IntVar("T_ints", covariant=True) # noqa
593+
T_ints = IntVar("T_ints", covariant=True)
594594

595595

596596
class LiteralTests(BaseTestCase):
@@ -936,7 +936,7 @@ def test_respect_no_type_check(self):
936936
@no_type_check
937937
class NoTpCheck:
938938
class Inn:
939-
def __init__(self, x: 'not a type'): ... # noqa
939+
def __init__(self, x: 'not a type'): ...
940940
self.assertTrue(NoTpCheck.__no_type_check__)
941941
self.assertTrue(NoTpCheck.Inn.__init__.__no_type_check__)
942942
self.assertEqual(gth(ann_module2.NTC.meth), {})

src/typing_extensions.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def __getitem__(self, parameters):
289289
instead of a type.""")
290290

291291

292-
_overload_dummy = typing._overload_dummy # noqa
292+
_overload_dummy = typing._overload_dummy
293293

294294

295295
if hasattr(typing, "get_overloads"): # 3.11+
@@ -478,7 +478,7 @@ def _no_init(self, *args, **kwargs):
478478
if type(self)._is_protocol:
479479
raise TypeError('Protocols cannot be instantiated')
480480

481-
class _ProtocolMeta(abc.ABCMeta): # noqa: B024
481+
class _ProtocolMeta(abc.ABCMeta):
482482
# This metaclass is a bit unfortunate and exists only because of the lack
483483
# of __instancehook__.
484484
def __instancecheck__(cls, instance):
@@ -545,7 +545,7 @@ def __class_getitem__(cls, params):
545545
raise TypeError(
546546
f"Parameter list to {cls.__qualname__}[...] cannot be empty")
547547
msg = "Parameters to generic types must be types."
548-
params = tuple(typing._type_check(p, msg) for p in params) # noqa
548+
params = tuple(typing._type_check(p, msg) for p in params)
549549
if cls is Protocol:
550550
# Generic can only be subscripted with unique type variables.
551551
if not all(isinstance(p, typing.TypeVar) for p in params):
@@ -1435,7 +1435,7 @@ def _concatenate_getitem(self, parameters):
14351435
# 3.10+
14361436
if hasattr(typing, 'Concatenate'):
14371437
Concatenate = typing.Concatenate
1438-
_ConcatenateGenericAlias = typing._ConcatenateGenericAlias # noqa
1438+
_ConcatenateGenericAlias = typing._ConcatenateGenericAlias # noqa: F811
14391439
# 3.9
14401440
elif sys.version_info[:2] >= (3, 9):
14411441
@_TypeAliasForm

test-requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
flake8
22
flake8-bugbear
3-
flake8-pyi>=22.8.0
3+
flake8-noqa

0 commit comments

Comments
 (0)