Skip to content

Commit 0a0b0f6

Browse files
Fix yapf
1 parent 414a228 commit 0a0b0f6

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ toml = "^0.10.2"
1919

2020
[tool.poetry.group.dev.dependencies]
2121
sphinx-autobuild = "^0.7.1"
22-
yapf = "^0.27.0"
22+
yapf = "^0.40.2"
2323

2424
[tool.poetry.group.test.dependencies]
2525
hypothesis = "^6.98.1"

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ commands =
1414
poetry run mypy typeclasses tests
1515
poetry run pylint typeclasses tests
1616
poetry run pydocstyle typeclasses tests
17+
poetry run yapf --recursive typeclasses tests --diff

typeclasses/decorator.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ def _code(function):
1818
If this Python interpreter does not supply the byte code for functions,
1919
then this function returns NaN so that all functions compare unequal.
2020
"""
21-
return (function.__code__.co_code
22-
if hasattr(function, '__code__') else float('nan'))
21+
return (
22+
function.__code__.co_code
23+
if hasattr(function, '__code__') else float('nan')
24+
)
2325

2426

2527
def _is_empty(function):
@@ -66,14 +68,16 @@ def __call__(self, *args, **kwargs):
6668

6769
if _is_empty(self.default_implementation):
6870
raise NotImplementedError(
69-
f'missing instance of {self.__name__} for {type_argument}')
71+
f'missing instance of {self.__name__} for {type_argument}'
72+
)
7073

7174
return self.default_implementation(*args, **kwargs)
7275

7376
def instance(self, type_argument, *, protocol=False):
7477
"""Declare an instance for this type class method."""
75-
instances = (self.protocol_instances
76-
if protocol else self.type_instances)
78+
instances = (
79+
self.protocol_instances if protocol else self.type_instances
80+
)
7781

7882
def decorator(implementation):
7983
instances[type_argument] = implementation
@@ -88,13 +92,15 @@ def typeclass(type_variable):
8892
def decorator(default_implementation):
8993
sig = inspect.signature(default_implementation)
9094
names = [
91-
p.name for p in sig.parameters.values()
95+
p.name
96+
for p in sig.parameters.values()
9297
if p.annotation == type_variable
9398
]
9499
if not names:
95100
raise TypeError(
96101
f'type variable `{type_variable}` missing from '
97-
f'signature of method `{default_implementation.__name__}`')
102+
f'signature of method `{default_implementation.__name__}`'
103+
)
98104
name = names[0]
99105

100106
def get_type_argument(*args, **kwargs):

0 commit comments

Comments
 (0)