|
7 | 7 | import functools |
8 | 8 | import itertools |
9 | 9 | import re |
| 10 | +import warnings |
10 | 11 |
|
11 | 12 | from ._compat import string_types, with_metaclass |
12 | 13 | from ._typing import TYPE_CHECKING |
13 | 14 | from .utils import canonicalize_version |
14 | 15 | from .version import Version, LegacyVersion, parse |
15 | 16 |
|
16 | 17 | if TYPE_CHECKING: # pragma: no cover |
17 | | - from typing import ( |
18 | | - List, |
19 | | - Dict, |
20 | | - Union, |
21 | | - Iterable, |
22 | | - Iterator, |
23 | | - Optional, |
24 | | - Callable, |
25 | | - Tuple, |
26 | | - FrozenSet, |
27 | | - ) |
| 18 | + from typing import List, Dict, Union, Iterable, Iterator, Optional, Callable, Tuple |
28 | 19 |
|
29 | 20 | ParsedVersion = Union[Version, LegacyVersion] |
30 | 21 | UnparsedVersion = Union[Version, LegacyVersion, str] |
@@ -285,6 +276,16 @@ class LegacySpecifier(_IndividualSpecifier): |
285 | 276 | ">": "greater_than", |
286 | 277 | } |
287 | 278 |
|
| 279 | + def __init__(self, spec="", prereleases=None): |
| 280 | + # type: (str, Optional[bool]) -> None |
| 281 | + super(LegacySpecifier, self).__init__(spec, prereleases) |
| 282 | + |
| 283 | + warnings.warn( |
| 284 | + "Creating a LegacyVersion has been deprecated and will be " |
| 285 | + "removed in the next major release", |
| 286 | + DeprecationWarning, |
| 287 | + ) |
| 288 | + |
288 | 289 | def _coerce_version(self, version): |
289 | 290 | # type: (Union[ParsedVersion, str]) -> LegacyVersion |
290 | 291 | if not isinstance(version, LegacyVersion): |
@@ -317,7 +318,7 @@ def _compare_greater_than(self, prospective, spec): |
317 | 318 |
|
318 | 319 |
|
319 | 320 | def _require_version_compare( |
320 | | - fn # type: (Callable[[Specifier, ParsedVersion, str], bool]) |
| 321 | + fn, # type: (Callable[[Specifier, ParsedVersion, str], bool]) |
321 | 322 | ): |
322 | 323 | # type: (...) -> Callable[[Specifier, ParsedVersion, str], bool] |
323 | 324 | @functools.wraps(fn) |
@@ -750,7 +751,7 @@ def __len__(self): |
750 | 751 | return len(self._specs) |
751 | 752 |
|
752 | 753 | def __iter__(self): |
753 | | - # type: () -> Iterator[FrozenSet[_IndividualSpecifier]] |
| 754 | + # type: () -> Iterator[_IndividualSpecifier] |
754 | 755 | return iter(self._specs) |
755 | 756 |
|
756 | 757 | @property |
|
0 commit comments