Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e20621b

Browse files
author
Guido van Rossum
committed
Silence pep8.
1 parent d47772d commit e20621b

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

prototyping/test_typing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,7 @@ class X(SimpleMapping[A, B]):
625625
def test_errors(self):
626626
with self.assertRaises(TypeError):
627627
B = SimpleMapping[XK, Any]
628+
628629
class C(Generic[B]):
629630
pass
630631

prototyping/typing.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,10 +1333,10 @@ def __init__(self, name, type_var, impl_type, type_checker):
13331333
assert isinstance(type_var, type), repr(type_var)
13341334
assert isinstance(impl_type, type), repr(impl_type)
13351335
assert not isinstance(impl_type, TypingMeta), repr(impl_type)
1336-
self.name = name # The name, e.g. 'Pattern'
1337-
self.type_var = type_var # The type parameter, e.g. 'AnyStr', or the specific type, e.g. 'str'
1338-
self.impl_type = impl_type # The implementation type
1339-
self.type_checker = type_checker # Function that takes an impl_type instance and returns a value that should be a type_var instance
1336+
self.name = name
1337+
self.type_var = type_var
1338+
self.impl_type = impl_type
1339+
self.type_checker = type_checker
13401340

13411341
def __repr__(self):
13421342
return "%s[%s]" % (self.name, _type_repr(self.type_var))
@@ -1346,22 +1346,28 @@ def __getitem__(self, parameter):
13461346
if not isinstance(self.type_var, TypeVar):
13471347
raise TypeError("%s cannot be further parameterized." % self)
13481348
if not issubclass(parameter, self.type_var):
1349-
raise TypeError("%s is not a valid substitution for %s." % (parameter, self.type_var))
1350-
return self.__class__(self.name, parameter, self.impl_type, self.type_checker)
1349+
raise TypeError("%s is not a valid substitution for %s." %
1350+
(parameter, self.type_var))
1351+
return self.__class__(self.name, parameter,
1352+
self.impl_type, self.type_checker)
13511353

13521354
def __instancecheck__(self, obj):
1353-
return isinstance(obj, self.impl_type) and isinstance(self.type_checker(obj), self.type_var)
1355+
return (isinstance(obj, self.impl_type) and
1356+
isinstance(self.type_checker(obj), self.type_var))
13541357

13551358
def __subclasscheck__(self, cls):
13561359
if isinstance(cls, _TypeAlias):
13571360
# Covariance. For now, we compare by name.
1358-
return (cls.name == self.name and issubclass(cls.type_var, self.type_var))
1361+
return (cls.name == self.name and
1362+
issubclass(cls.type_var, self.type_var))
13591363
else:
13601364
# Note that this is too lenient, because the
13611365
# implementation type doesn't carry information about
13621366
# whether it is about bytes or str (for example).
13631367
return issubclass(cls, self.impl_type)
13641368

13651369

1366-
Pattern = _TypeAlias('Pattern', AnyStr, type(re.compile('')), lambda p: p.pattern)
1367-
Match = _TypeAlias('Match', AnyStr, type(re.match('', '')), lambda m: m.re.pattern)
1370+
Pattern = _TypeAlias('Pattern', AnyStr, type(re.compile('')),
1371+
lambda p: p.pattern)
1372+
Match = _TypeAlias('Match', AnyStr, type(re.match('', '')),
1373+
lambda m: m.re.pattern)

0 commit comments

Comments
 (0)