Skip to content

Commit

Permalink
Version 3.15
Browse files Browse the repository at this point in the history
  • Loading branch information
mborsetti committed Oct 25, 2023
1 parent da0c604 commit e7adab0
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 35 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ Notice
Support for Python 3.8 will be removed on or about 5 October 2023. A reminder that older Python versions are
supported for 3 years after being obsoleted by a new major release (i.e. about 4 years since their original release).

Version 3.15rc1
Version 3.15
===================
Unreleased
2023-10-25

Added
-----
Expand Down
2 changes: 1 addition & 1 deletion webchanges/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# * MINOR version when you add functionality in a backwards compatible manner, and
# * MICRO or PATCH version when you make backwards compatible bug fixes. We no longer use '0'
# If unsure on increments, use pkg_resources.parse_version to parse
__version__ = '3.15rc1'
__version__ = '3.15'
__description__ = (
'Check web (or command output) for changes since last run and notify.\n'
'\n'
Expand Down
69 changes: 37 additions & 32 deletions webchanges/_vendored/packaging_version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Vendored version of packaging.version.parse() from packaging v23.1 released on 12-Apr-23
(commit https://github.com/pypa/packaging/tree/d563917280d65a6ce2e622bd3d07438e1ee259f3).
Vendored version of packaging.version.parse() from packaging v23.2 released on 01-Oct-23
(commit https://github.com/pypa/packaging/commit/7e4f2588923e647bb7c3d5b350473e39e4b279d4).
See https://github.com/pypa/packaging and https://github.com/pypa/packaging/blob/main/src/packaging/version.py.
Expand Down Expand Up @@ -216,10 +216,9 @@

from __future__ import annotations

import collections
import itertools
import re
from typing import Any, Callable, Optional, SupportsInt, Tuple, Union
from typing import Any, Callable, NamedTuple, Optional, SupportsInt, Tuple, Union

# `from webchanges._structures import Infinity, InfinityType, NegativeInfinity, NegativeInfinityType`
# replaced with the contents of the file
Expand Down Expand Up @@ -286,24 +285,31 @@ def __neg__(self: object) -> InfinityType:
# the following is the rest of the content of
# https://github.com/pypa/packaging/blob/main/src/packaging/version.py

InfiniteTypes = Union[InfinityType, NegativeInfinityType]
PrePostDevType = Union[InfiniteTypes, Tuple[str, int]]
SubLocalType = Union[InfiniteTypes, int, str]
LocalType = Union[
LocalType = Tuple[Union[int, str], ...]

CmpPrePostDevType = Union[InfinityType, NegativeInfinityType, Tuple[str, int]]
CmpLocalType = Union[
NegativeInfinityType,
Tuple[
Union[
SubLocalType,
Tuple[SubLocalType, str],
Tuple[NegativeInfinityType, SubLocalType],
],
...,
],
Tuple[Union[Tuple[int, str], Tuple[NegativeInfinityType, Union[int, str]]], ...],
]
CmpKey = Tuple[
int,
Tuple[int, ...],
CmpPrePostDevType,
CmpPrePostDevType,
CmpPrePostDevType,
CmpLocalType,
]
CmpKey = Tuple[int, Tuple[int, ...], PrePostDevType, PrePostDevType, PrePostDevType, LocalType]
VersionComparisonMethod = Callable[[CmpKey, CmpKey], bool]

_Version = collections.namedtuple('_Version', ['epoch', 'release', 'dev', 'pre', 'post', 'local'])

class _Version(NamedTuple):
epoch: int
release: Tuple[int, ...]
dev: Optional[Tuple[str, int]]
pre: Optional[Tuple[str, int]]
post: Optional[Tuple[str, int]]
local: Optional[LocalType]


def parse(version: str) -> 'Version':
Expand Down Expand Up @@ -378,7 +384,7 @@ def __ne__(self, other: object) -> bool:
(?P<release>[0-9]+(?:\.[0-9]+)*) # release segment
(?P<pre> # pre-release
[-_\.]?
(?P<pre_l>(a|b|c|rc|alpha|beta|pre|preview))
(?P<pre_l>alpha|a|beta|b|preview|pre|c|rc)
[-_\.]?
(?P<pre_n>[0-9]+)?
)?
Expand Down Expand Up @@ -526,8 +532,7 @@ def epoch(self) -> int:
>>> Version("1!2.0.0").epoch
1
"""
_epoch: int = self._version.epoch
return _epoch
return self._version.epoch

@property
def release(self) -> Tuple[int, ...]:
Expand All @@ -542,8 +547,7 @@ def release(self) -> Tuple[int, ...]:
Includes trailing zeroes but not the epoch or any pre-release / development / post-release suffixes.
"""
_release: Tuple[int, ...] = self._version.release
return _release
return self._version.release

@property
def pre(self) -> Optional[Tuple[str, int]]:
Expand All @@ -558,8 +562,7 @@ def pre(self) -> Optional[Tuple[str, int]]:
>>> Version("1.2.3rc1").pre
('rc', 1)
"""
_pre: Optional[Tuple[str, int]] = self._version.pre
return _pre
return self._version.pre

@property
def post(self) -> Optional[int]:
Expand Down Expand Up @@ -705,7 +708,9 @@ def micro(self) -> int:
return self.release[2] if len(self.release) >= 3 else 0


def _parse_letter_version(letter: str, number: Union[str, bytes, SupportsInt]) -> Optional[Tuple[str, int]]:
def _parse_letter_version(
letter: Optional[str], number: Union[str, bytes, SupportsInt, None]
) -> Optional[Tuple[str, int]]:
if letter:
# We consider there to be an implicit 0 in a pre-release if there is not a numeral associated with it.
if number is None:
Expand Down Expand Up @@ -739,7 +744,7 @@ def _parse_letter_version(letter: str, number: Union[str, bytes, SupportsInt]) -
_local_version_separators = re.compile(r'[\._-]')


def _parse_local_version(local: str) -> Optional[LocalType]:
def _parse_local_version(local: Optional[str]) -> Optional[LocalType]:
"""
Takes a string like abc.1.twelve and turns it into ("abc", 1, "twelve").
"""
Expand All @@ -756,7 +761,7 @@ def _cmpkey(
pre: Optional[Tuple[str, int]],
post: Optional[Tuple[str, int]],
dev: Optional[Tuple[str, int]],
local: Optional[Tuple[SubLocalType]],
local: Optional[LocalType],
) -> CmpKey:
# When we compare a release version, we want to compare it with all of the trailing zeros removed. So we'll use a
# reverse the list, drop all the now leading zeros until we come to something non zero, then take the rest
Expand All @@ -767,7 +772,7 @@ def _cmpkey(
# segment, but we _only_ want to do this if there is not a pre or a post segment. If we have one of those then
# the normal sorting rules will handle this case correctly.
if pre is None and post is None and dev is not None:
_pre: PrePostDevType = NegativeInfinity
_pre: CmpPrePostDevType = NegativeInfinity
# Versions without a pre-release (except as noted above) should sort after
# those with one.
elif pre is None:
Expand All @@ -777,21 +782,21 @@ def _cmpkey(

# Versions without a post segment should sort before those with one.
if post is None:
_post: PrePostDevType = NegativeInfinity
_post: CmpPrePostDevType = NegativeInfinity

else:
_post = post

# Versions without a development segment should sort after those with one.
if dev is None:
_dev: PrePostDevType = Infinity
_dev: CmpPrePostDevType = Infinity

else:
_dev = dev

if local is None:
# Versions without a local segment should sort before those with one.
_local: LocalType = NegativeInfinity
_local: CmpLocalType = NegativeInfinity
else:
# Versions with a local segment need that segment parsed to implement the sorting rules in PEP440.
# - Alpha numeric segments sort before numeric segments
Expand Down

0 comments on commit e7adab0

Please sign in to comment.