Skip to content

Commit e93b6de

Browse files
authored
Merge pull request #337 from mzjp2/fix/doc-max-suggestion
Improve suggestion for finding max and min using semver
2 parents 4631fa6 + 0398baa commit e93b6de

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

docs/migratetosemver3.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Use Version instead of VersionInfo
2020
The :class:`VersionInfo` has been renamed to :class:`Version`
2121
to have a more succinct name.
2222
An alias has been created to preserve compatibility but
23-
using old name has been deprecated.
23+
using the old name has been deprecated.
2424

2525
If you still need the old version, use this line:
2626

@@ -39,4 +39,4 @@ import it from :mod:`semver.cli` in the future:
3939

4040
.. code-block:: python
4141
42-
from semver.cli import cmd_bump
42+
from semver.cli import cmd_bump

docs/usage.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,9 +546,9 @@ For example, here are the maximum and minimum versions of a list of version stri
546546

547547
.. code-block:: python
548548
549-
>>> str(max(map(Version.parse, ['1.1.0', '1.2.0', '2.1.0', '0.5.10', '0.4.99'])))
549+
>>> max(['1.1.0', '1.2.0', '2.1.0', '0.5.10', '0.4.99'], key=Version.parse)
550550
'2.1.0'
551-
>>> str(min(map(Version.parse, ['1.1.0', '1.2.0', '2.1.0', '0.5.10', '0.4.99'])))
551+
>>> min(['1.1.0', '1.2.0', '2.1.0', '0.5.10', '0.4.99'], key=Version.parse)
552552
'0.4.99'
553553
554554
And the same can be done with tuples:

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)