Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Improve suggestion for finding max and min using semver #337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/migratetosemver3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Use Version instead of VersionInfo
The :class:`VersionInfo` has been renamed to :class:`Version`
to have a more succinct name.
An alias has been created to preserve compatibility but
using old name has been deprecated.
using the old name has been deprecated.

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

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

.. code-block:: python

from semver.cli import cmd_bump
from semver.cli import cmd_bump
4 changes: 2 additions & 2 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -546,9 +546,9 @@ For example, here are the maximum and minimum versions of a list of version stri

.. code-block:: python

>>> str(max(map(Version.parse, ['1.1.0', '1.2.0', '2.1.0', '0.5.10', '0.4.99'])))
>>> max(['1.1.0', '1.2.0', '2.1.0', '0.5.10', '0.4.99'], key=Version.parse)
'2.1.0'
>>> str(min(map(Version.parse, ['1.1.0', '1.2.0', '2.1.0', '0.5.10', '0.4.99'])))
>>> min(['1.1.0', '1.2.0', '2.1.0', '0.5.10', '0.4.99'], key=Version.parse)
'0.4.99'

And the same can be done with tuples:
Expand Down
6 changes: 3 additions & 3 deletions src/semver/_deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
import warnings
from functools import partial, wraps
from types import FrameType
from typing import Type, Union, Callable, cast
from typing import Type, Callable, cast

from . import cli
from .version import Version
from ._types import F, String
from ._types import Decorator, F, String


def deprecated(
func: F = None,
replace: str = None,
version: str = None,
category: Type[Warning] = DeprecationWarning,
) -> Union[Callable[..., F], partial]:
) -> Decorator:
"""
Decorates a function to output a deprecation warning.

Expand Down
2 changes: 2 additions & 0 deletions src/semver/_types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Typing for semver."""

from functools import partial
from typing import Union, Optional, Tuple, Dict, Iterable, Callable, TypeVar

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