|
3 | 3 | import warnings
|
4 | 4 | from typing import Any
|
5 | 5 | from typing import Callable
|
| 6 | +from typing import cast |
6 | 7 | from typing import Collection
|
7 | 8 | from typing import Iterable
|
8 | 9 | from typing import Iterator
|
@@ -266,7 +267,7 @@ def combined_with(self, other: "Mark") -> "Mark":
|
266 | 267 | # A generic parameter designating an object to which a Mark may
|
267 | 268 | # be applied -- a test function (callable) or class.
|
268 | 269 | # Note: a lambda is not allowed, but this can't be represented.
|
269 |
| -Markable = TypeVar("Markable", bound=Union[Callable[..., object], type]) |
| 270 | +Markable = TypeVar("Markable", bound=Callable[..., Any]) |
270 | 271 |
|
271 | 272 |
|
272 | 273 | @attr.s(init=False, auto_attribs=True)
|
@@ -348,21 +349,21 @@ def with_args(self, *args: object, **kwargs: object) -> "MarkDecorator":
|
348 | 349 | # return type. Not much we can do about that. Thankfully mypy picks
|
349 | 350 | # the first match so it works out even if we break the rules.
|
350 | 351 | @overload
|
351 |
| - def __call__(self, arg: Markable) -> Markable: # type: ignore[misc] |
| 352 | + def __call__(self, arg: Markable) -> Markable: |
352 | 353 | pass
|
353 | 354 |
|
354 | 355 | @overload
|
355 |
| - def __call__(self, *args: object, **kwargs: object) -> "MarkDecorator": |
| 356 | + def __call__(self, *args: Any, **kwargs: Any) -> "MarkDecorator": |
356 | 357 | pass
|
357 | 358 |
|
358 |
| - def __call__(self, *args: object, **kwargs: object): |
| 359 | + def __call__(self, *args: Any, **kwargs: Any) -> Union[Markable, "MarkDecorator"]: |
359 | 360 | """Call the MarkDecorator."""
|
360 | 361 | if args and not kwargs:
|
361 | 362 | func = args[0]
|
362 | 363 | is_class = inspect.isclass(func)
|
363 | 364 | if len(args) == 1 and (istestfunc(func) or is_class):
|
364 | 365 | store_mark(func, self.mark)
|
365 |
| - return func |
| 366 | + return cast(Markable, func) |
366 | 367 | return self.with_args(*args, **kwargs)
|
367 | 368 |
|
368 | 369 |
|
|
0 commit comments