Skip to content

Commit 8493e9a

Browse files
committed
Run pre-commit
1 parent 3240c83 commit 8493e9a

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

repo2docker/buildpacks/poetry/__init__.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
from ..conda import CondaBuildPack
1313

1414
# Minimum version of python for use with Poetry
15-
COMPATIBLE_PYTHON2_VERSIONS = parse_constraint('>=2.7')
15+
COMPATIBLE_PYTHON2_VERSIONS = parse_constraint(">=2.7")
1616

1717
# Min and max compatible versions of python3. N.B. the maximum constraint will
1818
# have to be manually bumped
19-
COMPATIBLE_PYTHON3_VERSIONS = parse_constraint('>=3.5, <3.10')
19+
COMPATIBLE_PYTHON3_VERSIONS = parse_constraint(">=3.5, <3.10")
20+
2021

2122
class PoetryBuildPack(CondaBuildPack):
2223
"""Setup Python with poetry for use with a repository."""
@@ -32,18 +33,17 @@ def python_version(self):
3233
if hasattr(self, "_python_version"):
3334
return self._python_version
3435

35-
requested_version = '*'
36+
requested_version = "*"
3637

3738
pyproject = self.binder_path("pyproject.toml")
3839
if os.path.exists(pyproject):
3940
with open(pyproject) as f:
4041
pyproject_info = toml.load(f)
4142
specified_version = (
42-
pyproject_info
43-
.get('tool', {})
44-
.get('poetry', {})
45-
.get('dependencies', {})
46-
.get('python', None)
43+
pyproject_info.get("tool", {})
44+
.get("poetry", {})
45+
.get("dependencies", {})
46+
.get("python", None)
4747
)
4848

4949
if not specified_version is None:
@@ -53,22 +53,21 @@ def python_version(self):
5353
if os.path.exists(lockfile):
5454
with open(lockfile) as f:
5555
lock_info = toml.load(f)
56-
specified_version = (
57-
lock_info.get('metadata', {})
58-
.get('python-versions', None)
56+
specified_version = lock_info.get("metadata", {}).get(
57+
"python-versions", None
5958
)
6059

6160
if not specified_version is None:
6261
requested_version = specified_version
6362

6463
requested_constraint = parse_constraint(requested_version)
6564

66-
version_range = parse_constraint('*')
65+
version_range = parse_constraint("*")
6766

68-
if requested_constraint.allows(parse_constraint('2')):
67+
if requested_constraint.allows(parse_constraint("2")):
6968
version_range = version_range.intersect(COMPATIBLE_PYTHON2_VERSIONS)
7069

71-
if requested_constraint.allows(parse_constraint('3')):
70+
if requested_constraint.allows(parse_constraint("3")):
7271
# If the given constraint allows for python 3, then this will
7372
# overwrite the range provided by python 2
7473
version_range = version_range.intersect(COMPATIBLE_PYTHON3_VERSIONS)
@@ -180,7 +179,9 @@ def detect(self):
180179
if os.path.exists(pyproject):
181180
with open(pyproject) as f:
182181
pyproject_info = toml.load(f)
183-
backend = pyproject_info.get('build-system', {}).get('build-backend', '')
184-
is_poetry = backend == 'poetry.masonry.api'
182+
backend = pyproject_info.get("build-system", {}).get(
183+
"build-backend", ""
184+
)
185+
is_poetry = backend == "poetry.masonry.api"
185186

186187
return is_poetry or os.path.exists(poetry_lock)

0 commit comments

Comments
 (0)