Skip to content

Commit 0398baa

Browse files
tomschrtlaferriere
andcommitted
Fix type definition problem
Define new type "Decorator" for function "deprecated" to avoid this mypy error: src/semver/_deprecated.py:69: error: Incompatible return value type (got "Callable[[VarArg(Any), KwArg(Any)], Callable[..., F]]", expected "Union[Callable[..., F], partial[Any]]") Co-authored-by: Thomas Laferriere <tlaferriere@users.noreply.github.com>
1 parent f74e3a3 commit 0398baa

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/semver/_deprecated.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77
import warnings
88
from functools import partial, wraps
99
from types import FrameType
10-
from typing import Type, Union, Callable, cast
10+
from typing import Type, Callable, cast
1111

1212
from . import cli
1313
from .version import Version
14-
from ._types import F, String
14+
from ._types import Decorator, F, String
1515

1616

1717
def deprecated(
1818
func: F = None,
1919
replace: str = None,
2020
version: str = None,
2121
category: Type[Warning] = DeprecationWarning,
22-
) -> Union[Callable[..., F], partial]:
22+
) -> Decorator:
2323
"""
2424
Decorates a function to output a deprecation warning.
2525

src/semver/_types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Typing for semver."""
22

3+
from functools import partial
34
from typing import Union, Optional, Tuple, Dict, Iterable, Callable, TypeVar
45

56
VersionPart = Union[int, Optional[str]]
@@ -8,3 +9,4 @@
89
VersionIterator = Iterable[VersionPart]
910
String = Union[str, bytes]
1011
F = TypeVar("F", bound=Callable)
12+
Decorator = Union[Callable[..., F], partial]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy