@@ -18,8 +18,10 @@ def _code(function):
18
18
If this Python interpreter does not supply the byte code for functions,
19
19
then this function returns NaN so that all functions compare unequal.
20
20
"""
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
+ )
23
25
24
26
25
27
def _is_empty (function ):
@@ -66,14 +68,16 @@ def __call__(self, *args, **kwargs):
66
68
67
69
if _is_empty (self .default_implementation ):
68
70
raise NotImplementedError (
69
- f'missing instance of { self .__name__ } for { type_argument } ' )
71
+ f'missing instance of { self .__name__ } for { type_argument } '
72
+ )
70
73
71
74
return self .default_implementation (* args , ** kwargs )
72
75
73
76
def instance (self , type_argument , * , protocol = False ):
74
77
"""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
+ )
77
81
78
82
def decorator (implementation ):
79
83
instances [type_argument ] = implementation
@@ -88,13 +92,15 @@ def typeclass(type_variable):
88
92
def decorator (default_implementation ):
89
93
sig = inspect .signature (default_implementation )
90
94
names = [
91
- p .name for p in sig .parameters .values ()
95
+ p .name
96
+ for p in sig .parameters .values ()
92
97
if p .annotation == type_variable
93
98
]
94
99
if not names :
95
100
raise TypeError (
96
101
f'type variable `{ type_variable } ` missing from '
97
- f'signature of method `{ default_implementation .__name__ } `' )
102
+ f'signature of method `{ default_implementation .__name__ } `'
103
+ )
98
104
name = names [0 ]
99
105
100
106
def get_type_argument (* args , ** kwargs ):
0 commit comments