Skip to content

Commit f986d61

Browse files
committed
Fix linter errors with Pyright
1 parent 5a4b101 commit f986d61

File tree

1 file changed

+18
-42
lines changed

1 file changed

+18
-42
lines changed

monic/expressions/registry.py

Lines changed: 18 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -43,31 +43,21 @@ def reset(self) -> None:
4343
self._modules = {}
4444

4545
@t.overload
46-
def bind(self, name_or_func: str) -> t.Callable[
47-
[t.Type[T] | t.Callable[..., T]],
48-
t.Type[T] | t.Callable[..., T],
49-
]: ...
46+
def bind(
47+
self, name_or_func: str, *, _obj: T | None = None
48+
) -> t.Callable[..., T]: ...
5049

5150
@t.overload
5251
def bind(self, name_or_func: t.Callable[..., T]) -> t.Callable[..., T]: ...
5352

54-
@t.overload
55-
def bind(self, name_or_func: t.Type[T]) -> t.Type[T]: ...
56-
57-
@t.overload
5853
def bind(
5954
self,
60-
) -> t.Callable[[t.Type[T]], t.Type[T]] | t.Callable[..., T]: ...
61-
62-
def bind(
63-
self, name_or_func: str | t.Callable[..., T] | t.Type[T] | None = None
55+
name_or_func: str | t.Callable[..., T] | None = None,
56+
*,
57+
_obj: T | None = None, # type: ignore
6458
) -> (
65-
t.Callable[
66-
[t.Type[T] | t.Callable[..., T]],
67-
t.Type[T] | t.Callable[..., T],
68-
]
69-
| t.Callable[..., T]
70-
| t.Type[T]
59+
t.Callable[..., T]
60+
| t.Callable[[t.Callable[..., T]], t.Callable[..., T]]
7161
):
7262
"""Bind an object with a given name.
7363
@@ -93,9 +83,7 @@ def bind(
9383
return self._bind_object(bind_name, name_or_func)
9484

9585
# Case 2: @monic_bind() or @monic_bind("custom.name")
96-
def decorator(
97-
obj: t.Callable[..., T] | t.Type[T]
98-
) -> t.Callable[..., T] | t.Type[T]:
86+
def decorator(obj: t.Callable[..., T]) -> t.Callable[..., T]:
9987
bind_name = name_or_func or getattr(obj, "__name__", None)
10088
if bind_name is None:
10189
raise ValueError(
@@ -268,33 +256,23 @@ def bind_module(
268256
return module
269257

270258
@t.overload
271-
def bind_default(self, name_or_func: str) -> t.Callable[
272-
[t.Type[T] | t.Callable[..., T]],
273-
t.Type[T] | t.Callable[..., T],
274-
]: ...
259+
def bind_default(
260+
self, name_or_func: str, *, _obj: T | None = None
261+
) -> t.Callable[..., T]: ...
275262

276263
@t.overload
277264
def bind_default(
278265
self, name_or_func: t.Callable[..., T]
279266
) -> t.Callable[..., T]: ...
280267

281-
@t.overload
282-
def bind_default(self, name_or_func: t.Type[T]) -> t.Type[T]: ...
283-
284-
@t.overload
285268
def bind_default(
286269
self,
287-
) -> t.Callable[[t.Type[T]], t.Type[T]] | t.Callable[..., T]: ...
288-
289-
def bind_default(
290-
self, name_or_func: str | t.Callable[..., T] | t.Type[T] | None = None
270+
name_or_func: str | t.Callable[..., T] | None = None,
271+
*,
272+
_obj: T | None = None, # type: ignore
291273
) -> (
292-
t.Callable[
293-
[t.Type[T] | t.Callable[..., T]],
294-
t.Type[T] | t.Callable[..., T],
295-
]
296-
| t.Callable[..., T]
297-
| t.Type[T]
274+
t.Callable[..., T]
275+
| t.Callable[[t.Callable[..., T]], t.Callable[..., T]]
298276
):
299277
"""Bind an object with a given name to the default registry.
300278
@@ -320,9 +298,7 @@ def bind_default(
320298
return self._bind_default_object(bind_name, name_or_func)
321299

322300
# Case 2: @bind_default() or @bind_default("custom.name")
323-
def decorator(
324-
obj: t.Callable[..., T] | t.Type[T]
325-
) -> t.Callable[..., T] | t.Type[T]:
301+
def decorator(obj: t.Callable[..., T]) -> t.Callable[..., T]:
326302
bind_name = name_or_func or getattr(obj, "__name__", None)
327303
if bind_name is None:
328304
raise ValueError(

0 commit comments

Comments
 (0)