-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
incompatibility_cause.py
81 lines (55 loc) · 1.86 KB
/
incompatibility_cause.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from poetry.mixology.incompatibility import Incompatibility
class IncompatibilityCause(Exception):
"""
The reason and Incompatibility's terms are incompatible.
"""
class RootCause(IncompatibilityCause):
pass
class NoVersionsCause(IncompatibilityCause):
pass
class DependencyCause(IncompatibilityCause):
pass
class ConflictCause(IncompatibilityCause):
"""
The incompatibility was derived from two existing incompatibilities
during conflict resolution.
"""
def __init__(self, conflict: Incompatibility, other: Incompatibility) -> None:
self._conflict = conflict
self._other = other
@property
def conflict(self) -> Incompatibility:
return self._conflict
@property
def other(self) -> Incompatibility:
return self._other
def __str__(self) -> str:
return str(self._conflict)
class PythonCause(IncompatibilityCause):
"""
The incompatibility represents a package's python constraint
(Python versions) being incompatible
with the current python version.
"""
def __init__(self, python_version: str, root_python_version: str) -> None:
self._python_version = python_version
self._root_python_version = root_python_version
@property
def python_version(self) -> str:
return self._python_version
@property
def root_python_version(self) -> str:
return self._root_python_version
class PlatformCause(IncompatibilityCause):
"""
The incompatibility represents a package's platform constraint
(OS most likely) being incompatible with the current platform.
"""
def __init__(self, platform: str) -> None:
self._platform = platform
@property
def platform(self) -> str:
return self._platform