File tree 2 files changed +18
-17
lines changed
2 files changed +18
-17
lines changed Original file line number Diff line number Diff line change @@ -409,7 +409,6 @@ def create_from_pep_508(
409
409
path is specified, this is used as the base directory if the identified dependency is
410
410
of file or directory type.
411
411
"""
412
- from poetry .core .semver .version import Version
413
412
from poetry .core .utils .patterns import wheel_file_re
414
413
from poetry .core .vcs .git import ParsedUrl
415
414
from poetry .core .version .requirements import Requirement
@@ -546,22 +545,6 @@ def create_from_pep_508(
546
545
op = ""
547
546
elif op == "!=" :
548
547
version += ".*"
549
- elif op in ("<=" , ">" ):
550
- parsed_version = Version .parse (version )
551
- if parsed_version .precision == 1 :
552
- if op == "<=" :
553
- op = "<"
554
- version = parsed_version .next_major ().text
555
- elif op == ">" :
556
- op = ">="
557
- version = parsed_version .next_major ().text
558
- elif parsed_version .precision == 2 :
559
- if op == "<=" :
560
- op = "<"
561
- version = parsed_version .next_minor ().text
562
- elif op == ">" :
563
- op = ">="
564
- version = parsed_version .next_minor ().text
565
548
elif op in ("in" , "not in" ):
566
549
versions = []
567
550
for v in re .split ("[ ,]+" , version ):
Original file line number Diff line number Diff line change 1
1
from poetry .core .packages .dependency import Dependency
2
+ from poetry .core .semver .version import Version
2
3
3
4
4
5
def test_dependency_from_pep_508 ():
@@ -254,3 +255,20 @@ def test_dependency_from_pep_508_with_python_full_version_pep440_compatible_rele
254
255
assert dep .name == "pathlib2"
255
256
assert str (dep .constraint ) == "*"
256
257
assert dep .python_versions == "~=3.4 || <3"
258
+
259
+
260
+ def test_dependency_from_pep_508_should_not_produce_empty_constraints_for_correct_markers ():
261
+ name = 'pytest-mypy; python_implementation != "PyPy" and python_version <= "3.10" and python_version > "3"'
262
+ dep = Dependency .create_from_pep_508 (name )
263
+
264
+ assert dep .name == "pytest-mypy"
265
+ assert str (dep .constraint ) == "*"
266
+ assert dep .python_versions == "<=3.10 >3"
267
+ assert dep .python_constraint .allows (Version .parse ("3.6" ))
268
+ assert dep .python_constraint .allows (Version .parse ("3.10" ))
269
+ assert not dep .python_constraint .allows (Version .parse ("3" ))
270
+ assert dep .python_constraint .allows (Version .parse ("3.0.1" ))
271
+ assert (
272
+ str (dep .marker )
273
+ == 'platform_python_implementation != "PyPy" and python_version <= "3.10" and python_version > "3"'
274
+ )
You can’t perform that action at this time.
0 commit comments