Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0398baa

Browse filesBrowse 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
Copy full SHA for 0398baa

File tree

2 files changed

+5
-3
lines changed
Filter options

2 files changed

+5
-3
lines changed

‎src/semver/_deprecated.py

Copy file name to clipboardExpand all lines: src/semver/_deprecated.py
+3-3Lines 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

Copy file name to clipboardExpand all lines: src/semver/_types.py
+2Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.