Skip to content

Improve flake8 config #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions .flake8-tests
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ ignore =
DW12,
# consistency with mypy
W504
noqa_require_code = true
6 changes: 3 additions & 3 deletions src/test_typing_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,15 +582,15 @@ 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):
T_ints = IntVar("T_ints", int)
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):
Expand Down Expand Up @@ -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), {})
Expand Down
8 changes: 4 additions & 4 deletions src/typing_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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+
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
flake8
flake8-bugbear
flake8-pyi>=22.8.0
flake8-noqa