Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
d99cb602
Unverified
Commit
d99cb602
authored
May 21, 2018
by
Sébastien Eustace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Keep original version's precision when expanding constraints
parent
4113773a
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
78 additions
and
34 deletions
+78
-34
CHANGELOG.md
+1
-0
poetry/semver/version.py
+27
-6
tests/console/commands/test_version.py
+2
-2
tests/installation/fixtures/with-optional-dependencies.test
+3
-3
tests/masonry/builders/test_complete.py
+3
-3
tests/masonry/builders/test_sdist.py
+10
-10
tests/packages/test_dependency.py
+9
-9
tests/semver/test_main.py
+22
-0
tests/test_poetry.py
+1
-1
No files found.
CHANGELOG.md
View file @
d99cb602
...
...
@@ -11,6 +11,7 @@
### Changed
-
Improved the
`show`
command to make it easier to check if packages are properly installed.
-
Expanded version constraints now keep the original version's precision.
## [0.9.1] - 2018-05-18
...
...
poetry/semver/version.py
View file @
d99cb602
...
...
@@ -15,14 +15,24 @@ class Version(VersionRange):
A parsed semantic version number.
"""
def
__init__
(
self
,
major
,
minor
=
None
,
patch
=
None
,
pre
=
None
,
build
=
None
,
text
=
None
):
# type: (int, int, int, Union[str, None], Union[str, None], Union[str, None])
def
__init__
(
self
,
major
,
# type: int
minor
=
None
,
# type: Union[int, None]
patch
=
None
,
# type: Union[int, None]
pre
=
None
,
# type: Union[str, None]
build
=
None
,
# type: Union[str, None]
text
=
None
,
# type: Union[str, None]
precision
=
None
# type: Union[str, None]
):
# type: () -> None
self
.
_major
=
int
(
major
)
self
.
_precision
=
None
if
precision
is
None
:
self
.
_precision
=
1
if
minor
is
None
:
minor
=
0
else
:
if
self
.
_precision
is
not
None
:
self
.
_precision
+=
1
self
.
_minor
=
int
(
minor
)
...
...
@@ -30,12 +40,23 @@ class Version(VersionRange):
if
patch
is
None
:
patch
=
0
else
:
if
self
.
_precision
is
not
None
:
self
.
_precision
+=
1
if
precision
is
not
None
:
self
.
_precision
=
precision
self
.
_patch
=
int
(
patch
)
if
text
is
None
:
text
=
'{}.{}.{}'
.
format
(
major
,
minor
,
patch
)
parts
=
[
str
(
major
)]
if
self
.
_precision
>=
2
or
minor
!=
0
:
parts
.
append
(
str
(
minor
))
if
self
.
_precision
>=
3
or
patch
!=
0
:
parts
.
append
(
str
(
patch
))
text
=
'.'
.
join
(
parts
)
if
pre
:
text
+=
'-{}'
.
format
(
pre
)
...
...
@@ -222,13 +243,13 @@ class Version(VersionRange):
return
self
def
_increment_major
(
self
):
# type: () -> Version
return
Version
(
self
.
major
+
1
,
0
,
0
)
return
Version
(
self
.
major
+
1
,
0
,
0
,
precision
=
self
.
_precision
)
def
_increment_minor
(
self
):
# type: () -> Version
return
Version
(
self
.
major
,
self
.
minor
+
1
,
0
)
return
Version
(
self
.
major
,
self
.
minor
+
1
,
0
,
precision
=
self
.
_precision
)
def
_increment_patch
(
self
):
# type: () -> Version
return
Version
(
self
.
major
,
self
.
minor
,
self
.
patch
+
1
)
return
Version
(
self
.
major
,
self
.
minor
,
self
.
patch
+
1
,
precision
=
self
.
_precision
)
def
_normalize_prerelease
(
self
,
pre
):
# type: (str) -> str
if
not
pre
:
...
...
tests/console/commands/test_version.py
View file @
d99cb602
...
...
@@ -14,8 +14,8 @@ def command():
(
'0.0.0'
,
'patch'
,
'0.0.1'
),
(
'0.0.0'
,
'minor'
,
'0.1.0'
),
(
'0.0.0'
,
'major'
,
'1.0.0'
),
(
'0.0'
,
'major'
,
'1.0
.0
'
),
(
'0.0'
,
'minor'
,
'0.1
.0
'
),
(
'0.0'
,
'major'
,
'1.0'
),
(
'0.0'
,
'minor'
,
'0.1'
),
(
'0.0'
,
'patch'
,
'0.0.1'
),
(
'1.2.3'
,
'patch'
,
'1.2.4'
),
(
'1.2.3'
,
'minor'
,
'1.3.0'
),
...
...
tests/installation/fixtures/with-optional-dependencies.test
View file @
d99cb602
...
...
@@ -17,7 +17,7 @@ python-versions = "*"
platform
=
"*"
[
package
.
requirements
]
python
=
">=2.4,<2.5
.0
"
python
=
">=2.4,<2.5"
[[
package
]]
name
=
"C"
...
...
@@ -32,7 +32,7 @@ platform = "*"
D
=
"^1.2"
[
package
.
requirements
]
python
=
">=2.7,<2.8
.0 || >=3.4,<4.0
.0"
python
=
">=2.7,<2.8
|| >=3.4,<4
.0"
[[
package
]]
name
=
"D"
...
...
@@ -44,7 +44,7 @@ python-versions = "*"
platform
=
"*"
[
package
.
requirements
]
python
=
">=2.7,<2.8
.0 || >=3.4,<4.0
.0"
python
=
">=2.7,<2.8
|| >=3.4,<4
.0"
[
metadata
]
python
-
versions
=
"~2.7 || ^3.4"
...
...
tests/masonry/builders/test_complete.py
View file @
d99cb602
...
...
@@ -114,7 +114,7 @@ License: MIT
Keywords: packaging,dependency,poetry
Author: Sébastien Eustace
Author-email: sebastien@eustace.io
Requires-Python: >=3.6,<4.0
.0
Requires-Python: >=3.6,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
...
...
@@ -123,8 +123,8 @@ Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Provides-Extra: time
Requires-Dist: cachy[msgpack] (>=0.2.0,<0.3.0)
Requires-Dist: cleo (>=0.6,<0.7
.0
)
Requires-Dist: pendulum (>=1.4,<2.0
.0
); extra == "time"
Requires-Dist: cleo (>=0.6,<0.7)
Requires-Dist: pendulum (>=1.4,<2.0); extra == "time"
Description-Content-Type: text/x-rst
My Package
...
...
tests/masonry/builders/test_sdist.py
View file @
d99cb602
...
...
@@ -48,8 +48,8 @@ def test_convert_dependencies():
]
)
main
=
[
'A>=1.0,<2.0
.0
'
,
'B>=1.0,<1.1
.0
'
,
'A>=1.0,<2.0'
,
'B>=1.0,<1.1'
,
'C==1.2.3'
,
]
extras
=
{}
...
...
@@ -70,7 +70,7 @@ def test_convert_dependencies():
]
)
main
=
[
'B>=1.0,<1.1
.0
'
,
'B>=1.0,<1.1'
,
'C==1.2.3'
,
]
extras
=
{
...
...
@@ -98,16 +98,16 @@ def test_convert_dependencies():
]
)
main
=
[
'B>=1.0,<1.1
.0
'
,
'B>=1.0,<1.1'
,
]
extra_python
=
(
':(python_version >= "2.7" and python_version < "2.8
.0
") '
'or (python_version >= "3.6" and python_version < "4.0
.0
")'
':(python_version >= "2.7" and python_version < "2.8") '
'or (python_version >= "3.6" and python_version < "4.0")'
)
extra_d_dependency
=
(
'baz:(python_version >= "2.7" and python_version < "2.8
.0
") '
'or (python_version >= "3.4" and python_version < "4.0
.0
")'
'baz:(python_version >= "2.7" and python_version < "2.8") '
'or (python_version >= "3.4" and python_version < "4.0")'
)
extras
=
{
extra_python
:
[
'C==1.2.3'
],
...
...
@@ -134,7 +134,7 @@ def test_make_setup():
]
assert
ns
[
'install_requires'
]
==
[
'cachy[msgpack]>=0.2.0,<0.3.0'
,
'cleo>=0.6,<0.7
.0
'
,
'cleo>=0.6,<0.7'
,
]
assert
ns
[
'entry_points'
]
==
{
'console_scripts'
:
[
...
...
@@ -144,7 +144,7 @@ def test_make_setup():
}
assert
ns
[
'extras_require'
]
==
{
'time'
:
[
'pendulum>=1.4,<2.0
.0
'
'pendulum>=1.4,<2.0'
]
}
...
...
tests/packages/test_dependency.py
View file @
d99cb602
...
...
@@ -59,15 +59,15 @@ def test_to_pep_508():
dependency
=
Dependency
(
'Django'
,
'^1.23'
)
result
=
dependency
.
to_pep_508
()
assert
result
==
'Django (>=1.23,<2.0
.0
)'
assert
result
==
'Django (>=1.23,<2.0)'
dependency
=
Dependency
(
'Django'
,
'^1.23'
)
dependency
.
python_versions
=
'~2.7 || ^3.6'
result
=
dependency
.
to_pep_508
()
assert
result
==
'Django (>=1.23,<2.0
.0
); '
\
'(python_version >= "2.7" and python_version < "2.8
.0
") '
\
'or (python_version >= "3.6" and python_version < "4.0
.0
")'
assert
result
==
'Django (>=1.23,<2.0); '
\
'(python_version >= "2.7" and python_version < "2.8") '
\
'or (python_version >= "3.6" and python_version < "4.0")'
def
test_to_pep_508_wilcard
():
...
...
@@ -82,21 +82,21 @@ def test_to_pep_508_in_extras():
dependency
.
in_extras
.
append
(
'foo'
)
result
=
dependency
.
to_pep_508
()
assert
result
==
'Django (>=1.23,<2.0
.0
); extra == "foo"'
assert
result
==
'Django (>=1.23,<2.0); extra == "foo"'
dependency
.
in_extras
.
append
(
'bar'
)
result
=
dependency
.
to_pep_508
()
assert
result
==
'Django (>=1.23,<2.0
.0
); extra == "foo" or extra == "bar"'
assert
result
==
'Django (>=1.23,<2.0); extra == "foo" or extra == "bar"'
dependency
.
python_versions
=
'~2.7 || ^3.6'
result
=
dependency
.
to_pep_508
()
assert
result
==
(
'Django (>=1.23,<2.0
.0
); '
'Django (>=1.23,<2.0); '
'('
'(python_version >= "2.7" and python_version < "2.8
.0
") '
'or (python_version >= "3.6" and python_version < "4.0
.0
")'
'(python_version >= "2.7" and python_version < "2.8") '
'or (python_version >= "3.6" and python_version < "4.0")'
') '
'and (extra == "foo" or extra == "bar")'
)
tests/semver/test_main.py
View file @
d99cb602
...
...
@@ -120,3 +120,25 @@ def test_parse_constraint_multi(input):
)
def
test_parse_constraints_negative_wildcard
(
input
,
constraint
):
assert
parse_constraint
(
input
)
==
constraint
@pytest.mark.parametrize
(
'input, expected'
,
[
(
'1'
,
'1'
),
(
'1.2'
,
'1.2'
),
(
'1.2.3'
,
'1.2.3'
),
(
'!=1'
,
'<1 || >1'
),
(
'!=1.2'
,
'<1.2 || >1.2'
),
(
'!=1.2.3'
,
'<1.2.3 || >1.2.3'
),
(
'^1'
,
'>=1,<2'
),
(
'^1.0'
,
'>=1.0,<2.0'
),
(
'^1.0.0'
,
'>=1.0.0,<2.0.0'
),
(
'~1'
,
'>=1,<2'
),
(
'~1.0'
,
'>=1.0,<1.1'
),
(
'~1.0.0'
,
'>=1.0.0,<1.1.0'
),
]
)
def
test_constraints_keep_version_precision
(
input
,
expected
):
assert
str
(
parse_constraint
(
input
))
==
expected
tests/test_poetry.py
View file @
d99cb602
...
...
@@ -27,7 +27,7 @@ def test_poetry():
assert
package
.
keywords
==
[
"packaging"
,
"dependency"
,
"poetry"
]
assert
package
.
python_versions
==
'~2.7 || ^3.6'
assert
str
(
package
.
python_constraint
)
==
'>=2.7,<2.8
.0 || >=3.6,<4.0
.0'
assert
str
(
package
.
python_constraint
)
==
'>=2.7,<2.8
|| >=3.6,<4
.0'
dependencies
=
{}
for
dep
in
package
.
requires
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment