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
66bb5644
Commit
66bb5644
authored
Apr 21, 2023
by
Bartek Sokorski
Committed by
Bartosz Sokorski
Apr 24, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate from flake8 to ruff
parent
dd483c8c
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
115 additions
and
143 deletions
+115
-143
.flake8
+0
-36
.pre-commit-config.yaml
+5
-25
pyproject.toml
+35
-0
src/poetry/console/application.py
+1
-1
src/poetry/console/commands/remove.py
+3
-2
src/poetry/console/logging/io_handler.py
+1
-1
src/poetry/inspection/info.py
+1
-1
src/poetry/installation/chef.py
+1
-1
src/poetry/installation/executor.py
+1
-1
src/poetry/puzzle/provider.py
+25
-25
src/poetry/puzzle/solver.py
+3
-3
src/poetry/repositories/pypi_repository.py
+1
-1
src/poetry/repositories/repository_pool.py
+1
-4
src/poetry/utils/env.py
+1
-1
src/poetry/vcs/git/system.py
+2
-1
tests/console/commands/self/test_self_command.py
+3
-3
tests/console/commands/test_init.py
+1
-4
tests/packages/test_locker.py
+17
-17
tests/repositories/test_installed_repository.py
+1
-1
tests/repositories/test_lockfile_repository.py
+2
-2
tests/repositories/test_pypi_repository.py
+3
-6
tests/repositories/test_repository_pool.py
+1
-1
tests/repositories/test_single_page_repository.py
+2
-2
tests/utils/test_env_site.py
+2
-2
tests/utils/test_helpers.py
+1
-1
tests/utils/test_patterns.py
+1
-1
No files found.
.flake8
deleted
100644 → 0
View file @
dd483c8c
[flake8]
min_python_version = 3.7.0
max-line-length = 88
ban-relative-imports = true
# flake8-use-fstring: https://github.com/MichaelKim0407/flake8-use-fstring#--percent-greedy-and---format-greedy
format-greedy = 1
inline-quotes = double
enable-extensions = TC, TC1
type-checking-strict = true
eradicate-whitelist-extend = ^-.*;
extend-ignore =
# E203: Whitespace before ':' (pycqa/pycodestyle#373)
E203,
# SIM106: Handle error-cases first
SIM106,
# ANN101: Missing type annotation for self in method
ANN101,
# ANN102: Missing type annotation for cls in classmethod
ANN102,
# PIE781: assign-and-return
PIE781,
# PIE798 no-unnecessary-class: Consider using a module for namespacing instead
PIE798,
per-file-ignores =
# TC002: Move third-party import '...' into a type-checking block
__init__.py:TC002,
# ANN201: Missing return type annotation for public function
tests/test_*:ANN201
tests/**/test_*:ANN201
extend-exclude =
# Frozen and not subject to change in this repo:
get-poetry.py,
install-poetry.py,
# External to the project's coding standards:
tests/fixtures/*,
tests/**/fixtures/*,
.pre-commit-config.yaml
View file @
66bb5644
...
...
@@ -27,24 +27,6 @@ repos:
-
id
:
python-use-type-annotations
-
id
:
python-check-blanket-noqa
-
repo
:
https://github.com/asottile/yesqa
rev
:
v1.4.0
hooks
:
-
id
:
yesqa
additional_dependencies
:
&flake8_deps
-
flake8-annotations==3.0.0
-
flake8-bugbear==23.1.20
-
flake8-comprehensions==3.10.1
-
flake8-eradicate==1.4.0
-
flake8-pie==0.16.0
-
flake8-quotes==3.3.2
-
flake8-simplify==0.19.3
-
flake8-tidy-imports==4.8.0
-
flake8-type-checking==2.3.0
-
flake8-typing-imports==1.14.0
-
flake8-use-fstring==1.4
-
pep8-naming==0.13.3
-
repo
:
https://github.com/asottile/pyupgrade
rev
:
v3.3.1
hooks
:
...
...
@@ -80,14 +62,12 @@ repos:
hooks
:
-
id
:
black
-
repo
:
https://github.com/pycqa/flake8
# freeze to commit rev to prevent automatic updates, since newer versions of flake8 are not compatible with plugins
rev
:
6027577d325b0dd8bf1e465ebd29b71b5f0d005b
hooks
:
-
id
:
flake8
additional_dependencies
:
*flake8_deps
-
repo
:
https://github.com/pre-commit/pre-commit
rev
:
v2.21.0
hooks
:
-
id
:
validate_manifest
-
repo
:
https://github.com/charliermarsh/ruff-pre-commit
rev
:
v0.0.262
hooks
:
-
id
:
ruff
pyproject.toml
View file @
66bb5644
...
...
@@ -122,6 +122,41 @@ requires = ["poetry-core>=1.1.0"]
build-backend
=
"poetry.core.masonry.api"
[tool.ruff]
fix
=
true
unfixable
=
[
"ERA"
,
# do not autoremove commented out code
]
target-version
=
"py37"
line-length
=
88
extend-select
=
[
"B"
,
# flake8-bugbear
"C4"
,
# flake8-comprehensions
"ERA"
,
# flake8-eradicate/eradicate
"PIE"
,
# flake8-pie
"SIM"
,
# flake8-simplify
"TID"
,
# flake8-tidy-imports
"TCH"
,
# flake8-type-checking
"N"
,
# pep8-naming
"RUF"
,
# ruff checks
]
ignore
=
[
"B904"
,
# use 'raise ... from err'
"B905"
,
# use explicit 'strict=' parameter with 'zip()'
"N818"
# Exception name should be named with an Error suffix
]
extend-exclude
=
[
"docs/*"
,
# Frozen and not subject to change in this repo
"install-poetry.py"
,
# External to the project's coding standards
"tests/**/fixtures/*"
,
]
[tool.ruff.flake8-tidy-imports]
ban-relative-imports
=
"all"
[tool.isort]
py_version
=
37
profile
=
"black"
...
...
src/poetry/console/application.py
View file @
66bb5644
...
...
@@ -202,7 +202,7 @@ class Application(BaseApplication):
from
poetry.console.io.inputs.run_argv_input
import
RunArgvInput
input
=
cast
(
"ArgvInput"
,
io
.
input
)
run_input
=
RunArgvInput
([
self
.
_name
or
""
]
+
input
.
_tokens
)
run_input
=
RunArgvInput
([
self
.
_name
or
""
,
*
input
.
_tokens
]
)
# For the run command reset the definition
# with only the set options (i.e. the options given before the command)
for
option_name
,
value
in
input
.
options
.
items
():
...
...
src/poetry/console/commands/remove.py
View file @
66bb5644
...
...
@@ -67,8 +67,9 @@ list of installed packages
]
for
group_name
,
section
in
[
(
MAIN_GROUP
,
poetry_content
[
"dependencies"
])
]
+
group_sections
:
(
MAIN_GROUP
,
poetry_content
[
"dependencies"
]),
*
group_sections
,
]:
removed
+=
self
.
_remove_packages
(
packages
,
section
,
group_name
)
if
group_name
!=
MAIN_GROUP
:
if
not
section
:
...
...
src/poetry/console/logging/io_handler.py
View file @
66bb5644
...
...
@@ -26,5 +26,5 @@ class IOHandler(logging.Handler):
self
.
_io
.
write_error_line
(
msg
)
else
:
self
.
_io
.
write_line
(
msg
)
except
Exception
:
# noqa: PIE786
except
Exception
:
self
.
handleError
(
record
)
src/poetry/inspection/info.py
View file @
66bb5644
...
...
@@ -63,7 +63,7 @@ PEP517_META_BUILD_DEPS = ["build==0.10.0", "pyproject_hooks==1.0.0"]
class
PackageInfoError
(
ValueError
):
def
__init__
(
self
,
path
:
Path
,
*
reasons
:
BaseException
|
str
)
->
None
:
reasons
=
(
f
"Unable to determine package info for path: {path!s}"
,
)
+
reasons
reasons
=
(
f
"Unable to determine package info for path: {path!s}"
,
*
reasons
)
super
()
.
__init__
(
"
\n\n
"
.
join
(
str
(
msg
)
.
strip
()
for
msg
in
reasons
if
msg
))
...
...
src/poetry/installation/chef.py
View file @
66bb5644
...
...
@@ -155,7 +155,7 @@ class Chef:
context
:
Callable
[
[
str
],
AbstractContextManager
[
zipfile
.
ZipFile
|
tarfile
.
TarFile
]
]
if
suffix
==
".zip"
:
if
suffix
==
".zip"
:
# noqa: SIM108
context
=
zipfile
.
ZipFile
else
:
context
=
tarfile
.
open
...
...
src/poetry/installation/executor.py
View file @
66bb5644
...
...
@@ -291,7 +291,7 @@ class Executor:
# error to be picked up by the error handler.
if
result
==
-
2
:
raise
KeyboardInterrupt
except
Exception
as
e
:
# noqa: PIE786
except
Exception
as
e
:
try
:
from
cleo.ui.exception_trace
import
ExceptionTrace
...
...
src/poetry/puzzle/provider.py
View file @
66bb5644
...
...
@@ -671,18 +671,18 @@ class Provider:
# the requirements will be merged.
#
# For instance:
#
-
enum34; python_version=="2.7"
#
-
enum34; python_version=="3.3"
#
•
enum34; python_version=="2.7"
#
•
enum34; python_version=="3.3"
#
# will become:
#
-
enum34; python_version=="2.7" or python_version=="3.3"
#
•
enum34; python_version=="2.7" or python_version=="3.3"
#
# If the duplicate dependencies have different constraints
# we have to split the dependency graph.
#
# An example of this is:
#
-
pypiwin32 (220); sys_platform == "win32" and python_version >= "3.6"
#
-
pypiwin32 (219); sys_platform == "win32" and python_version < "3.6"
#
•
pypiwin32 (220); sys_platform == "win32" and python_version >= "3.6"
#
•
pypiwin32 (219); sys_platform == "win32" and python_version < "3.6"
duplicates
:
dict
[
str
,
list
[
Dependency
]]
=
defaultdict
(
list
)
for
dep
in
dependencies
:
duplicates
[
dep
.
complete_name
]
.
append
(
dep
)
...
...
@@ -702,19 +702,19 @@ class Provider:
for
group
in
dep_groups
:
# In order to reduce the number of overrides we merge duplicate
# dependencies by constraint. For instance, if we have:
#
-
foo (>=2.0) ; python_version >= "3.6" and python_version < "3.7"
#
-
foo (>=2.0) ; python_version >= "3.7"
#
•
foo (>=2.0) ; python_version >= "3.6" and python_version < "3.7"
#
•
foo (>=2.0) ; python_version >= "3.7"
# we can avoid two overrides by merging them to:
#
-
foo (>=2.0) ; python_version >= "3.6"
#
•
foo (>=2.0) ; python_version >= "3.6"
# However, if we want to merge dependencies by constraint we have to
# merge dependencies by markers first in order to avoid unnecessary
# solver failures. For instance, if we have:
#
-
foo (>=2.0) ; python_version >= "3.6" and python_version < "3.7"
#
-
foo (>=2.0) ; python_version >= "3.7"
#
-
foo (<2.1) ; python_version >= "3.7"
#
•
foo (>=2.0) ; python_version >= "3.6" and python_version < "3.7"
#
•
foo (>=2.0) ; python_version >= "3.7"
#
•
foo (<2.1) ; python_version >= "3.7"
# we must not merge the first two constraints but the last two:
#
-
foo (>=2.0) ; python_version >= "3.6" and python_version < "3.7"
#
-
foo (>=2.0,<2.1) ; python_version >= "3.7"
#
•
foo (>=2.0) ; python_version >= "3.6" and python_version < "3.7"
#
•
foo (>=2.0,<2.1) ; python_version >= "3.7"
deps
+=
self
.
_merge_dependencies_by_constraint
(
self
.
_merge_dependencies_by_marker
(
group
)
)
...
...
@@ -748,13 +748,13 @@ class Provider:
# tell the solver to make new resolutions with specific overrides.
#
# For instance, if the foo (1.2.3) package has the following dependencies:
#
-
bar (>=2.0) ; python_version >= "3.6"
#
-
bar (<2.0) ; python_version < "3.6"
#
•
bar (>=2.0) ; python_version >= "3.6"
#
•
bar (<2.0) ; python_version < "3.6"
#
# then the solver will need to make two new resolutions
# with the following overrides:
#
-
{<Package foo (1.2.3): {"bar": <Dependency bar (>=2.0)>}
#
-
{<Package foo (1.2.3): {"bar": <Dependency bar (<2.0)>}
#
•
{<Package foo (1.2.3): {"bar": <Dependency bar (>=2.0)>}
#
•
{<Package foo (1.2.3): {"bar": <Dependency bar (<2.0)>}
def
fmt_warning
(
d
:
Dependency
)
->
str
:
dependency_marker
=
d
.
marker
if
not
d
.
marker
.
is_any
()
else
"*"
...
...
@@ -1005,16 +1005,16 @@ class Provider:
environment markers to the inverse of the union of the
other dependencies markers.
For instance, if we have the following dependencies:
-
ipython
-
ipython (1.2.4) ; implementation_name == "pypy"
•
ipython
•
ipython (1.2.4) ; implementation_name == "pypy"
the marker for `ipython` will become `implementation_name != "pypy"`.
Further, we have to merge the constraints of the requirements
without markers into the constraints of the requirements with markers.
for instance, if we have the following dependencies:
-
foo (>= 1.2)
-
foo (!= 1.2.1) ; python == 3.10
•
foo (>= 1.2)
•
foo (!= 1.2.1) ; python == 3.10
the constraint for the second entry will become (!= 1.2.1, >= 1.2).
"""
...
...
@@ -1052,10 +1052,10 @@ class Provider:
# and the inverted marker is not empty,
# a dependency with the inverted union of all markers is required
# in order to not miss other dependencies later, for instance:
#
-
foo (1.0) ; python == 3.7
#
-
foo (2.0) ; python == 3.8
#
-
bar (2.0) ; python == 3.8
#
-
bar (3.0) ; python == 3.9
#
•
foo (1.0) ; python == 3.7
#
•
foo (2.0) ; python == 3.8
#
•
bar (2.0) ; python == 3.8
#
•
bar (3.0) ; python == 3.9
#
# the last dependency would be missed without this,
# because the intersection with both foo dependencies is empty.
...
...
src/poetry/puzzle/solver.py
View file @
66bb5644
...
...
@@ -75,12 +75,12 @@ class Solver:
if
len
(
self
.
_overrides
)
>
1
:
self
.
_provider
.
debug
(
# ignore the warning as provider does not do interpolation
f
"Complete version solving took {end - start:.3f}"
# noqa: PIE803
f
"Complete version solving took {end - start:.3f}"
f
" seconds with {len(self._overrides)} overrides"
)
self
.
_provider
.
debug
(
# ignore the warning as provider does not do interpolation
"Resolved with overrides:"
# noqa: PIE803
"Resolved with overrides:"
f
" {', '.join(f'({b})' for b in self._overrides)}"
)
...
...
@@ -126,7 +126,7 @@ class Solver:
for
override
in
overrides
:
self
.
_provider
.
debug
(
# ignore the warning as provider does not do interpolation
"<comment>Retrying dependency resolution "
# noqa: PIE803
"<comment>Retrying dependency resolution "
f
"with the following overrides ({override}).</comment>"
)
self
.
_provider
.
set_overrides
(
override
)
...
...
src/poetry/repositories/pypi_repository.py
View file @
66bb5644
...
...
@@ -246,5 +246,5 @@ class PyPiRepository(HTTPRepository):
@staticmethod
def
_get_yanked
(
json_data
:
dict
[
str
,
Any
])
->
str
|
bool
:
if
json_data
.
get
(
"yanked"
,
False
):
return
json_data
.
get
(
"yanked_reason"
)
or
True
# noqa: SIM222
return
json_data
.
get
(
"yanked_reason"
)
or
True
return
False
src/poetry/repositories/repository_pool.py
View file @
66bb5644
...
...
@@ -130,10 +130,7 @@ class RepositoryPool(AbstractRepository):
DeprecationWarning
,
stacklevel
=
2
,
)
if
default
:
priority
=
Priority
.
DEFAULT
else
:
priority
=
Priority
.
SECONDARY
priority
=
Priority
.
DEFAULT
if
default
else
Priority
.
SECONDARY
if
priority
is
Priority
.
DEFAULT
and
self
.
has_default
():
raise
ValueError
(
"Only one repository can be the default."
)
...
...
src/poetry/utils/env.py
View file @
66bb5644
...
...
@@ -1944,7 +1944,7 @@ class NullEnv(SystemEnv):
return
""
def
execute
(
self
,
bin
:
str
,
*
args
:
str
,
**
kwargs
:
Any
)
->
int
:
self
.
executed
.
append
([
bin
]
+
list
(
args
)
)
self
.
executed
.
append
([
bin
,
*
list
(
args
)]
)
if
self
.
_execute
:
return
super
()
.
execute
(
bin
,
*
args
,
**
kwargs
)
...
...
src/poetry/vcs/git/system.py
View file @
66bb5644
...
...
@@ -47,7 +47,8 @@ class SystemGit:
(
folder
/
".git"
)
.
as_posix
(),
"--work-tree"
,
folder
.
as_posix
(),
)
+
args
*
args
,
)
git_command
=
find_git_command
()
env
=
os
.
environ
.
copy
()
...
...
tests/console/commands/self/test_self_command.py
View file @
66bb5644
...
...
@@ -12,7 +12,7 @@ from poetry.factory import Factory
@pytest.fixture
def
example_system_pyproject
():
def
example_system_pyproject
()
->
str
:
package
=
ProjectPackage
(
"poetry-instance"
,
__version__
)
plugin
=
Package
(
"poetry-plugin"
,
"1.2.3"
)
...
...
@@ -27,7 +27,7 @@ def example_system_pyproject():
def
test_generate_system_pyproject_trailing_newline
(
existing_newlines
:
int
,
example_system_pyproject
:
str
,
):
)
->
None
:
cmd
=
SelfCommand
()
cmd
.
system_pyproject
.
write_text
(
example_system_pyproject
+
"
\n
"
*
existing_newlines
)
cmd
.
generate_system_pyproject
()
...
...
@@ -38,7 +38,7 @@ def test_generate_system_pyproject_trailing_newline(
def
test_generate_system_pyproject_carriage_returns
(
example_system_pyproject
:
str
,
):
)
->
None
:
cmd
=
SelfCommand
()
cmd
.
system_pyproject
.
write_text
(
example_system_pyproject
+
"
\n
"
)
cmd
.
generate_system_pyproject
()
...
...
tests/console/commands/test_init.py
View file @
66bb5644
...
...
@@ -1049,10 +1049,7 @@ def test_package_include(
),
)
if
include
is
None
:
packages
=
""
else
:
packages
=
f
'packages = [{{include = "{include}"}}]
\n
'
packages
=
""
if
include
is
None
else
f
'packages = [{{include = "{include}"}}]
\n
'
expected
=
(
f
"[tool.poetry]
\n
"
...
...
tests/packages/test_locker.py
View file @
66bb5644
...
...
@@ -188,7 +188,7 @@ url = "https://example.org/url-package-1.0-cp39-win_amd64.whl"
lock-version = "2.0"
python-versions = "*"
content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8"
"""
# noqa: E800
"""
assert
content
==
expected
...
...
@@ -221,7 +221,7 @@ redis = ["redis (>=2.10.5)"]
lock-version = "2.0"
python-versions = "~2.7 || ^3.4"
content-hash = "c3d07fca33fba542ef2b2a4d75bf5b48d892d21a830e2ad9c952ba5123a52f77"
"""
# noqa: E800
"""
with
open
(
locker
.
lock
,
"w"
,
encoding
=
"utf-8"
)
as
f
:
f
.
write
(
content
)
...
...
@@ -282,7 +282,7 @@ files = []
python-versions = "*"
lock-version = "2.0"
content-hash = "123456789"
"""
# noqa: E800
"""
with
open
(
locker
.
lock
,
"w"
,
encoding
=
"utf-8"
)
as
f
:
f
.
write
(
content
)
...
...
@@ -346,7 +346,7 @@ files = []
python-versions = "*"
lock-version = "2.0"
content-hash = "123456789"
"""
# noqa: E800
"""
with
open
(
locker
.
lock
,
"w"
,
encoding
=
"utf-8"
)
as
f
:
f
.
write
(
content
)
...
...
@@ -537,7 +537,7 @@ files = []
lock-version = "2.0"
python-versions = "*"
content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8"
"""
# noqa: E800
"""
assert
content
==
expected
...
...
@@ -579,7 +579,7 @@ foo = ["B (>=1.0.0)"]
lock-version = "2.0"
python-versions = "*"
content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8"
"""
# noqa: E800
"""
with
locker
.
lock
.
open
(
encoding
=
"utf-8"
)
as
f
:
content
=
f
.
read
()
...
...
@@ -611,7 +611,7 @@ foo = ["bar"]
lock-version = "2.0"
python-versions = "*"
content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8"
"""
# noqa: E800
"""
with
locker
.
lock
.
open
(
"w"
,
encoding
=
"utf-8"
)
as
f
:
f
.
write
(
content
)
...
...
@@ -658,7 +658,7 @@ reference = "legacy"
lock-version = "2.0"
python-versions = "*"
content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8"
"""
# noqa: E800
"""
assert
content
==
expected
...
...
@@ -703,7 +703,7 @@ def test_locker_should_raise_an_error_if_lock_version_is_newer_and_not_allowed(
lock-version = "3.0"
python-versions = "~2.7 || ^3.4"
content-hash = "c3d07fca33fba542ef2b2a4d75bf5b48d892d21a830e2ad9c952ba5123a52f77"
"""
# noqa: E800
"""
caplog
.
set_level
(
logging
.
WARNING
,
logger
=
"poetry.packages.locker"
)
with
open
(
locker
.
lock
,
"w"
,
encoding
=
"utf-8"
)
as
f
:
...
...
@@ -740,7 +740,7 @@ C = ["first", "second", "third"]
lock-version = "2.0"
python-versions = "*"
content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8"
"""
# noqa: E800
"""
with
locker
.
lock
.
open
(
encoding
=
"utf-8"
)
as
f
:
content
=
f
.
read
()
...
...
@@ -778,7 +778,7 @@ B = {{version = "^1.0.0", extras = ["a", "b", "c"], optional = true}}
lock-version = "2.0"
python-versions = "*"
content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8"
"""
# noqa: E800
"""
with
locker
.
lock
.
open
(
encoding
=
"utf-8"
)
as
f
:
content
=
f
.
read
()
...
...
@@ -891,7 +891,7 @@ I = {{git = "https://github.com/python-poetry/poetry.git", rev = "spam"}}
lock-version = "2.0"
python-versions = "*"
content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8"
"""
# noqa: E800
"""
assert
content
==
expected
...
...
@@ -935,7 +935,7 @@ subdirectory = "subdir"
lock-version = "2.0"
python-versions = "*"
content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8"
"""
# noqa: E800
"""
assert
content
==
expected
...
...
@@ -979,7 +979,7 @@ C = ["first (==1.0.0)", "second (==1.0.0)", "third (==1.0.0)"]
lock-version = "2.0"
python-versions = "*"
content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8"
"""
# noqa: E800
"""
assert
content
==
expected
...
...
@@ -1010,7 +1010,7 @@ url = "lib/libA"
lock-version = "2.0"
python-versions = "*"
content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8"
"""
# noqa: E800
"""
with
open
(
locker
.
lock
,
"w"
,
encoding
=
"utf-8"
)
as
f
:
f
.
write
(
content
)
...
...
@@ -1155,7 +1155,7 @@ resolved_reference = "123456"
lock-version = "2.0"
python-versions = "*"
content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8"
"""
# noqa: E800
"""
assert
content
==
expected
...
...
@@ -1173,7 +1173,7 @@ package = []
lock-version = "2.0"
python-versions = "*"
content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8"
"""
# noqa: E800
"""
with
open
(
locker
.
lock
,
"w"
,
encoding
=
"utf-8"
)
as
f
:
f
.
write
(
old_content
)
...
...
tests/repositories/test_installed_repository.py
View file @
66bb5644
...
...
@@ -107,7 +107,7 @@ def test_load_successful_with_invalid_distribution(
invalid_dist_info
.
mkdir
(
parents
=
True
)
mocker
.
patch
(
"poetry.utils._compat.metadata.Distribution.discover"
,
return_value
=
INSTALLED_RESULTS
+
[
metadata
.
PathDistribution
(
invalid_dist_info
)],
return_value
=
[
*
INSTALLED_RESULTS
,
metadata
.
PathDistribution
(
invalid_dist_info
)],
)
repository_with_invalid_distribution
=
InstalledRepository
.
load
(
env
)
...
...
tests/repositories/test_lockfile_repository.py
View file @
66bb5644
...
...
@@ -7,7 +7,7 @@ from poetry.core.packages.package import Package
from
poetry.repositories.lockfile_repository
import
LockfileRepository
def
test_has_package
():
def
test_has_package
()
->
None
:
repo
=
LockfileRepository
()
url_package
=
Package
(
...
...
@@ -32,7 +32,7 @@ def test_has_package():
assert
repo
.
has_package
(
deepcopy
(
url_package_2
))
def
test_remove_package
():
def
test_remove_package
()
->
None
:
url_package
=
Package
(
"a"
,
"1.0"
,
source_type
=
"url"
,
source_url
=
"https://example.org/a.whl"
)
...
...
tests/repositories/test_pypi_repository.py
View file @
66bb5644
...
...
@@ -51,10 +51,7 @@ class MockRepository(PyPiRepository):
)
->
dict
[
str
,
Any
]
|
None
:
parts
=
url
.
split
(
"/"
)[
1
:]
name
=
parts
[
0
]
if
len
(
parts
)
==
3
:
version
=
parts
[
1
]
else
:
version
=
None
version
=
parts
[
1
]
if
len
(
parts
)
==
3
else
None
if
not
version
:
fixture
=
self
.
JSON_FIXTURES
/
(
name
+
".json"
)
...
...
@@ -340,7 +337,7 @@ def test_urls() -> None:
assert
repository
.
authenticated_url
==
"https://pypi.org/simple/"
def
test_find_links_for_package_of_supported_types
():
def
test_find_links_for_package_of_supported_types
()
->
None
:
repo
=
MockRepository
()
package
=
repo
.
find_packages
(
Factory
.
create_dependency
(
"hbmqtt"
,
"0.9.6"
))
...
...
@@ -353,7 +350,7 @@ def test_find_links_for_package_of_supported_types():
assert
links
[
0
]
.
show_url
==
"hbmqtt-0.9.6.tar.gz"
def
test_get_release_info_includes_only_supported_types
():
def
test_get_release_info_includes_only_supported_types
()
->
None
:
repo
=
MockRepository
()
release_info
=
repo
.
_get_release_info
(
name
=
"hbmqtt"
,
version
=
"0.9.6"
)
...
...
tests/repositories/test_repository_pool.py
View file @
66bb5644
...
...
@@ -81,7 +81,7 @@ def test_repository_from_single_repo_pool_legacy(
assert
pool
.
get_priority
(
"foo"
)
==
expected_priority
def
test_repository_with_normal_default_secondary_and_explicit_repositories
():
def
test_repository_with_normal_default_secondary_and_explicit_repositories
()
->
None
:
secondary
=
LegacyRepository
(
"secondary"
,
"https://secondary.com"
)
default
=
LegacyRepository
(
"default"
,
"https://default.com"
)
repo1
=
LegacyRepository
(
"foo"
,
"https://foo.bar"
)
...
...
tests/repositories/test_single_page_repository.py
View file @
66bb5644
...
...
@@ -38,7 +38,7 @@ class MockSinglePageRepository(SinglePageRepository):
raise
RuntimeError
(
"Tests are not configured for downloads"
)
def
test_single_page_repository_get_page
():
def
test_single_page_repository_get_page
()
->
None
:
repo
=
MockSinglePageRepository
(
"jax_releases"
)
page
=
repo
.
get_page
(
"/ignored"
)
...
...
@@ -52,7 +52,7 @@ def test_single_page_repository_get_page():
assert
link
.
path
.
startswith
(
"/jax-releases/"
)
def
test_single_page_repository_find_packages
():
def
test_single_page_repository_find_packages
()
->
None
:
repo
=
MockSinglePageRepository
(
"jax_releases"
)
dep
=
Dependency
(
"jaxlib"
,
"0.3.7"
)
...
...
tests/utils/test_env_site.py
View file @
66bb5644
...
...
@@ -12,7 +12,7 @@ if TYPE_CHECKING:
from
pytest_mock
import
MockerFixture
def
test_env_site_simple
(
tmp_path
:
Path
,
mocker
:
MockerFixture
):
def
test_env_site_simple
(
tmp_path
:
Path
,
mocker
:
MockerFixture
)
->
None
:
# emulate permission error when creating directory
mocker
.
patch
(
"pathlib.Path.mkdir"
,
side_effect
=
OSError
())
site_packages
=
SitePackages
(
Path
(
"/non-existent"
),
fallbacks
=
[
tmp_path
])
...
...
@@ -30,7 +30,7 @@ def test_env_site_simple(tmp_path: Path, mocker: MockerFixture):
assert
not
(
site_packages
.
path
/
"hello.txt"
)
.
exists
()
def
test_env_site_select_first
(
tmp_path
:
Path
):
def
test_env_site_select_first
(
tmp_path
:
Path
)
->
None
:
fallback
=
tmp_path
/
"fallback"
fallback
.
mkdir
(
parents
=
True
)
...
...
tests/utils/test_helpers.py
View file @
66bb5644
...
...
@@ -42,7 +42,7 @@ zipfile36>=0.1.0.0,<0.2.0.0
[dev]
isort@ git+git://github.com/timothycrosley/isort.git@e63ae06ec7d70b06df9e528357650281a3d3ec22#egg=isort
"""
# noqa: E501
"""
result
=
parse_requires
(
requires
)
# fmt: off
expected
=
[
...
...
tests/utils/test_patterns.py
View file @
66bb5644
...
...
@@ -34,7 +34,7 @@ from poetry.utils import patterns
),
],
)
def
test_wheel_file_re
(
filename
:
str
,
expected
:
dict
[
str
,
str
|
None
]):
def
test_wheel_file_re
(
filename
:
str
,
expected
:
dict
[
str
,
str
|
None
])
->
None
:
match
=
patterns
.
wheel_file_re
.
match
(
filename
)
groups
=
match
.
groupdict
()
...
...
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