Skip to content

Commit d25b3cc

Browse files
authored
Merge pull request #45 from ssanderson/pin-black
STY: Update and pin black version.
2 parents 4f9a396 + e4b0119 commit d25b3cc

File tree

5 files changed

+31
-15
lines changed

5 files changed

+31
-15
lines changed

.pre-commit-config.yaml

+2-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ repos:
2323
hooks:
2424
- id: isort
2525

26-
- repo: https://github.com/ambv/black
27-
rev: stable
26+
- repo: https://github.com/psf/black
27+
rev: 20.8b1
2828
hooks:
2929
- id: black
30-
language_version: python3.6

interface/default.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88

99
class default(object):
10-
"""Default implementation of a function in terms of interface methods.
11-
"""
10+
"""Default implementation of a function in terms of interface methods."""
1211

1312
def __init__(self, implementation):
1413
self.implementation = implementation
@@ -32,8 +31,7 @@ class UnsafeDefault(UserWarning):
3231
)
3332

3433
def warn_if_defaults_use_non_interface_members(interface_name, defaults, members):
35-
"""Warn if an interface default uses non-interface members of self.
36-
"""
34+
"""Warn if an interface default uses non-interface members of self."""
3735
for method_name, attrs in non_member_attributes(defaults, members):
3836
warnings.warn(
3937
_DEFAULT_USES_NON_INTERFACE_MEMBER_TEMPLATE.format(

interface/interface.py

+21-7
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ def _conflicting_defaults(typename, conflicts):
8181
The following interfaces provided default implementations for {attr!r}:
8282
{interfaces}"""
8383
).format(
84-
attr=attrname, interfaces=bulleted_list(sorted(map(getname, interfaces))),
84+
attr=attrname,
85+
interfaces=bulleted_list(sorted(map(getname, interfaces))),
8586
)
8687
return InvalidImplementation(message)
8788

@@ -116,7 +117,9 @@ def __new__(mcls, name, bases, clsdict):
116117
errmsg = (
117118
"Couldn't parse signature for field "
118119
"{iface_name}.{fieldname} of type {attrtype}.".format(
119-
iface_name=name, fieldname=field, attrtype=getname(type(v)),
120+
iface_name=name,
121+
fieldname=field,
122+
attrtype=getname(type(v)),
120123
)
121124
)
122125
raise_from(TypeError(errmsg), e)
@@ -131,7 +134,10 @@ def __new__(mcls, name, bases, clsdict):
131134
"\nInterface field {new}.{field} conflicts with inherited field of "
132135
"the same name.\n"
133136
" - {field}{new_sig} != {field}{old_sig}".format(
134-
new=name, field=field, new_sig=signature, old_sig=conflicted,
137+
new=name,
138+
field=field,
139+
new_sig=signature,
140+
old_sig=conflicted,
135141
)
136142
)
137143
else:
@@ -228,7 +234,8 @@ def _invalid_implementation(self, t, missing, mistyped, mismatched):
228234
assert missing or mistyped or mismatched, "Implementation wasn't invalid."
229235

230236
message = "\nclass {C} failed to implement interface {I}:".format(
231-
C=getname(t), I=getname(self),
237+
C=getname(t),
238+
I=getname(self),
232239
)
233240
if missing:
234241
message += dedent(
@@ -293,7 +300,9 @@ def _format_mismatched_methods(self, mismatched):
293300
sorted(
294301
[
295302
" - {name}{actual} != {name}{expected}".format(
296-
name=name, actual=bad_sig, expected=self._signatures[name],
303+
name=name,
304+
actual=bad_sig,
305+
expected=self._signatures[name],
297306
)
298307
for name, bad_sig in mismatched.items()
299308
]
@@ -470,7 +479,9 @@ def format_iface_method_docs(I):
470479
return "\n".join(
471480
[
472481
"{iface_name}.{method_name}{sig}".format(
473-
iface_name=iface_name, method_name=method_name, sig=sig,
482+
iface_name=iface_name,
483+
method_name=method_name,
484+
sig=sig,
474485
)
475486
for method_name, sig in sorted(list(I._signatures.items()), key=first)
476487
]
@@ -564,7 +575,10 @@ def method2(self, y):
564575
)
565576

566577
result = ImplementsMeta(
567-
name, (object,), {"__doc__": doc}, interfaces=interfaces,
578+
name,
579+
(object,),
580+
{"__doc__": doc},
581+
interfaces=interfaces,
568582
)
569583

570584
# NOTE: It's important for correct weak-memoization that this is set is

interface/tests/test_interface.py

+4
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,7 @@ def method_b(self):
903903

904904
# expected to fail since it's missing method_b
905905
with pytest.raises(InvalidImplementation) as exc:
906+
906907
class JustA(implements(AandB)): # pragma: nocover
907908
def method_a(self):
908909
pass
@@ -919,6 +920,7 @@ class JustA failed to implement interface AandB:
919920

920921
# expected to fail since it's missing method_a
921922
with pytest.raises(InvalidImplementation) as exc:
923+
922924
class JustB(implements(AandB)): # pragma: nocover
923925
def method_b(self):
924926
pass
@@ -958,6 +960,7 @@ def method_b(self):
958960

959961
# expected to fail since method_a has different signature in interface A
960962
with pytest.raises(TypeError) as exc:
963+
961964
class C1(A): # pragma: nocover
962965
def method_a(self, x):
963966
pass
@@ -972,6 +975,7 @@ def method_a(self, x):
972975

973976
# expected to fail since method_b has different signature in interface B
974977
with pytest.raises(TypeError) as exc:
978+
975979
class C2(B): # pragma: nocover
976980
def method_b(self, y, z=None):
977981
pass

interface/typed_signature.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ def __str__(self):
4747

4848
def __repr__(self):
4949
return "<TypedSignature type={}, signature={}>".format(
50-
self._type.__name__, self._signature,
50+
self._type.__name__,
51+
self._signature,
5152
)
5253

5354

0 commit comments

Comments
 (0)