Skip to content

Commit

Permalink
Update ruff and black (#8586)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby authored Oct 28, 2023
1 parent f59728d commit a949a6b
Show file tree
Hide file tree
Showing 19 changed files with 76 additions and 75 deletions.
5 changes: 3 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@ repos:
- id: check-docstring-first

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.9.1
rev: 23.10.1
hooks:
- id: black
exclude: tests/([^/]*/)*fixtures/

- repo: https://github.com/pre-commit/pre-commit
rev: v3.4.0
hooks:
- id: validate_manifest

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.291
rev: v0.1.3
hooks:
- id: ruff
26 changes: 13 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,20 @@ build-backend = "poetry.core.masonry.api"


[tool.ruff]
extend-exclude = [
"docs/*",
# External to the project's coding standards
"tests/**/fixtures/*",
]
fix = true
line-length = 88
src = ["src"]
target-version = "py38"

[tool.ruff.lint]
unfixable = [
"ERA", # do not autoremove commented out code
]
target-version = "py38"
line-length = 88
extend-select = [
"B", # flake8-bugbear
"C4", # flake8-comprehensions
Expand All @@ -116,16 +124,11 @@ ignore = [
"B905", # use explicit 'strict=' parameter with 'zip()'
"N818", # Exception name should be named with an Error suffix
]
extend-exclude = [
"docs/*",
# External to the project's coding standards
"tests/**/fixtures/*",
]

[tool.ruff.flake8-tidy-imports]
[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"

[tool.ruff.isort]
[tool.ruff.lint.isort]
force-single-line = true
lines-between-types = 1
lines-after-imports = 2
Expand All @@ -139,10 +142,7 @@ required-imports = ["from __future__ import annotations"]
[tool.black]
target-version = ['py38']
preview = true
force-exclude = '''
.*/setup\.py$
'''

extend-exclude = "tests/([^/]*/)*fixtures/"

[tool.mypy]
files = "src, tests"
Expand Down
2 changes: 1 addition & 1 deletion src/poetry/console/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def _get_solution_provider_repository(self) -> SolutionProviderRepository:
SolutionProviderRepository,
)

from poetry.mixology.solutions.providers.python_requirement_solution_provider import ( # noqa: E501
from poetry.mixology.solutions.providers.python_requirement_solution_provider import (
PythonRequirementSolutionProvider,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ def solution_description(self) -> str:
@property
def documentation_links(self) -> list[str]:
return [
"https://python-poetry.org/docs/dependency-specification/#python-restricted-dependencies", # noqa: E501
"https://python-poetry.org/docs/dependency-specification/#using-environment-markers", # noqa: E501
"https://python-poetry.org/docs/dependency-specification/#python-restricted-dependencies",
"https://python-poetry.org/docs/dependency-specification/#using-environment-markers",
]
2 changes: 1 addition & 1 deletion src/poetry/mixology/version_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def _resolve_conflict(self, incompatibility: Incompatibility) -> Incompatibility
# details.
#
# .. _algorithm documentation:
# https://github.com/dart-lang/pub/tree/master/doc/solver.md#conflict-resolution # noqa: E501
# https://github.com/dart-lang/pub/tree/master/doc/solver.md#conflict-resolution
if difference is not None:
inverse = difference.inverse
if inverse.dependency != most_recent_satisfier.dependency:
Expand Down
2 changes: 1 addition & 1 deletion src/poetry/publishing/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def _get_type(self, file: Path) -> str:
raise ValueError("Unknown distribution format " + "".join(exts))

def _is_file_exists_error(self, response: requests.Response) -> bool:
# based on https://github.com/pypa/twine/blob/a6dd69c79f7b5abfb79022092a5d3776a499e31b/twine/commands/upload.py#L32 # noqa: E501
# based on https://github.com/pypa/twine/blob/a6dd69c79f7b5abfb79022092a5d3776a499e31b/twine/commands/upload.py#L32
status = response.status_code
reason = response.reason.lower()
text = response.text.lower()
Expand Down
6 changes: 3 additions & 3 deletions src/poetry/utils/authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ def __init__(
self._sessions_for_netloc: dict[str, requests.Session] = {}
self._credentials: dict[str, HTTPAuthCredential] = {}
self._certs: dict[str, RepositoryCertificateConfig] = {}
self._configured_repositories: dict[
str, AuthenticatorRepositoryConfig
] | None = None
self._configured_repositories: (
dict[str, AuthenticatorRepositoryConfig] | None
) = None
self._password_manager = PasswordManager(self._config)
self._cache_control = (
FileCache(
Expand Down
12 changes: 6 additions & 6 deletions tests/installation/test_chooser.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def test_chooser_chooses_distributions_that_match_the_package_hashes(
package = Package("isort", "4.3.4")
files = [
{
"hash": "sha256:b9c40e9750f3d77e6e4d441d8b0266cf555e7cdabdcff33c4fd06366ca761ef8", # noqa: E501
"hash": "sha256:b9c40e9750f3d77e6e4d441d8b0266cf555e7cdabdcff33c4fd06366ca761ef8",
"filename": "isort-4.3.4.tar.gz",
}
]
Expand Down Expand Up @@ -311,7 +311,7 @@ def test_chooser_chooses_yanked_if_no_others(
files = [
{
"filename": "black-21.11b0-py3-none-any.whl",
"hash": "sha256:0b1f66cbfadcd332ceeaeecf6373d9991d451868d2e2219ad0ac1213fb701117", # noqa: E501
"hash": "sha256:0b1f66cbfadcd332ceeaeecf6373d9991d451868d2e2219ad0ac1213fb701117",
}
]
if source_type == "legacy":
Expand Down Expand Up @@ -342,11 +342,11 @@ def test_chooser_does_not_choose_yanked_if_others(
files = [
{
"filename": "futures-3.2.0-py2-none-any.whl",
"hash": "sha256:ec0a6cb848cc212002b9828c3e34c675e0c9ff6741dc445cab6fdd4e1085d1f1", # noqa: E501
"hash": "sha256:ec0a6cb848cc212002b9828c3e34c675e0c9ff6741dc445cab6fdd4e1085d1f1",
},
{
"filename": "futures-3.2.0.tar.gz",
"hash": "sha256:9ec02aa7d674acb8618afb127e27fde7fc68994c0437ad759fa094a574adb265", # noqa: E501
"hash": "sha256:9ec02aa7d674acb8618afb127e27fde7fc68994c0437ad759fa094a574adb265",
},
]
package = Package(
Expand Down Expand Up @@ -387,7 +387,7 @@ def test_chooser_throws_an_error_if_package_hashes_do_not_match(
package = Package("isort", "4.3.4")
files = [
{
"hash": "sha256:0000000000000000000000000000000000000000000000000000000000000000", # noqa: E501
"hash": "sha256:0000000000000000000000000000000000000000000000000000000000000000",
"filename": "isort-4.3.4.tar.gz",
}
]
Expand Down Expand Up @@ -421,7 +421,7 @@ def test_chooser_md5_remote_fallback_to_sha256_inline_calculation(
)
package.files = [
{
"hash": "sha256:9fa123ad707a5c6c944743bf3e11a0e80d86cb518d3cf25320866ca3ef43e2ad", # noqa: E501
"hash": "sha256:9fa123ad707a5c6c944743bf3e11a0e80d86cb518d3cf25320866ca3ef43e2ad",
"filename": "demo-0.1.0.tar.gz",
}
]
Expand Down
20 changes: 10 additions & 10 deletions tests/installation/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,11 +473,11 @@ def test_execute_works_with_ansi_output(

# fmt: off
expected = [
"\x1b[39;1mPackage operations\x1b[39;22m: \x1b[34m1\x1b[39m install, \x1b[34m0\x1b[39m updates, \x1b[34m0\x1b[39m removals", # noqa: E501
"\x1b[34;1m•\x1b[39;22m \x1b[39mInstalling \x1b[39m\x1b[36mcleo\x1b[39m\x1b[39m (\x1b[39m\x1b[39;1m1.0.0a5\x1b[39;22m\x1b[39m)\x1b[39m: \x1b[34mPending...\x1b[39m", # noqa: E501
"\x1b[34;1m•\x1b[39;22m \x1b[39mInstalling \x1b[39m\x1b[36mcleo\x1b[39m\x1b[39m (\x1b[39m\x1b[39;1m1.0.0a5\x1b[39;22m\x1b[39m)\x1b[39m: \x1b[34mDownloading...\x1b[39m", # noqa: E501
"\x1b[34;1m•\x1b[39;22m \x1b[39mInstalling \x1b[39m\x1b[36mcleo\x1b[39m\x1b[39m (\x1b[39m\x1b[39;1m1.0.0a5\x1b[39;22m\x1b[39m)\x1b[39m: \x1b[34mInstalling...\x1b[39m", # noqa: E501
"\x1b[32;1m•\x1b[39;22m \x1b[39mInstalling \x1b[39m\x1b[36mcleo\x1b[39m\x1b[39m (\x1b[39m\x1b[32m1.0.0a5\x1b[39m\x1b[39m)\x1b[39m", # finished # noqa: E501
"\x1b[39;1mPackage operations\x1b[39;22m: \x1b[34m1\x1b[39m install, \x1b[34m0\x1b[39m updates, \x1b[34m0\x1b[39m removals",
"\x1b[34;1m•\x1b[39;22m \x1b[39mInstalling \x1b[39m\x1b[36mcleo\x1b[39m\x1b[39m (\x1b[39m\x1b[39;1m1.0.0a5\x1b[39;22m\x1b[39m)\x1b[39m: \x1b[34mPending...\x1b[39m",
"\x1b[34;1m•\x1b[39;22m \x1b[39mInstalling \x1b[39m\x1b[36mcleo\x1b[39m\x1b[39m (\x1b[39m\x1b[39;1m1.0.0a5\x1b[39;22m\x1b[39m)\x1b[39m: \x1b[34mDownloading...\x1b[39m",
"\x1b[34;1m•\x1b[39;22m \x1b[39mInstalling \x1b[39m\x1b[36mcleo\x1b[39m\x1b[39m (\x1b[39m\x1b[39;1m1.0.0a5\x1b[39;22m\x1b[39m)\x1b[39m: \x1b[34mInstalling...\x1b[39m",
"\x1b[32;1m•\x1b[39;22m \x1b[39mInstalling \x1b[39m\x1b[36mcleo\x1b[39m\x1b[39m (\x1b[39m\x1b[32m1.0.0a5\x1b[39m\x1b[39m)\x1b[39m", # finished
]
# fmt: on

Expand Down Expand Up @@ -669,7 +669,7 @@ def test_executor_should_not_write_pep610_url_references_for_cached_package(
package.files = [
{
"file": "demo-0.1.0-py2.py3-none-any.whl",
"hash": "sha256:70e704135718fffbcbf61ed1fc45933cfd86951a744b681000eaaa75da31f17a", # noqa: E501
"hash": "sha256:70e704135718fffbcbf61ed1fc45933cfd86951a744b681000eaaa75da31f17a",
}
]

Expand All @@ -696,7 +696,7 @@ def test_executor_should_write_pep610_url_references_for_wheel_files(
package.files = [
{
"file": "demo-0.1.0-py2.py3-none-any.whl",
"hash": "sha256:70e704135718fffbcbf61ed1fc45933cfd86951a744b681000eaaa75da31f17a", # noqa: E501
"hash": "sha256:70e704135718fffbcbf61ed1fc45933cfd86951a744b681000eaaa75da31f17a",
}
]

Expand Down Expand Up @@ -729,7 +729,7 @@ def test_executor_should_write_pep610_url_references_for_non_wheel_files(
package.files = [
{
"file": "demo-0.1.0.tar.gz",
"hash": "sha256:9fa123ad707a5c6c944743bf3e11a0e80d86cb518d3cf25320866ca3ef43e2ad", # noqa: E501
"hash": "sha256:9fa123ad707a5c6c944743bf3e11a0e80d86cb518d3cf25320866ca3ef43e2ad",
}
]

Expand Down Expand Up @@ -838,7 +838,7 @@ def test_executor_should_write_pep610_url_references_for_wheel_urls(
package.files = [
{
"file": "demo-0.1.0-py2.py3-none-any.whl",
"hash": "sha256:70e704135718fffbcbf61ed1fc45933cfd86951a744b681000eaaa75da31f17a", # noqa: E501
"hash": "sha256:70e704135718fffbcbf61ed1fc45933cfd86951a744b681000eaaa75da31f17a",
}
]

Expand Down Expand Up @@ -928,7 +928,7 @@ def mock_get_cached_archive_for_link_func(
package.files = [
{
"file": "demo-0.1.0.tar.gz",
"hash": "sha256:9fa123ad707a5c6c944743bf3e11a0e80d86cb518d3cf25320866ca3ef43e2ad", # noqa: E501
"hash": "sha256:9fa123ad707a5c6c944743bf3e11a0e80d86cb518d3cf25320866ca3ef43e2ad",
}
]

Expand Down
8 changes: 4 additions & 4 deletions tests/installation/test_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ def test_run_install_does_not_remove_locked_packages_if_installed_but_not_requir
assert installer.executor.removals_count == 0


def test_run_install_removes_locked_packages_if_installed_and_synchronization_is_required( # noqa: E501
def test_run_install_removes_locked_packages_if_installed_and_synchronization_is_required(
installer: Installer,
locker: Locker,
repo: Repository,
Expand Down Expand Up @@ -1852,7 +1852,7 @@ def test_run_install_duplicate_dependencies_different_constraints_with_lock_upda
@pytest.mark.skip(
"This is not working at the moment due to limitations in the resolver"
)
def test_installer_test_solver_finds_compatible_package_for_dependency_python_not_fully_compatible_with_package_python( # noqa: E501
def test_installer_test_solver_finds_compatible_package_for_dependency_python_not_fully_compatible_with_package_python(
installer: Installer,
locker: Locker,
repo: Repository,
Expand Down Expand Up @@ -1881,7 +1881,7 @@ def test_installer_test_solver_finds_compatible_package_for_dependency_python_no
assert installer.executor.installations_count == 1


def test_installer_required_extras_should_not_be_removed_when_updating_single_dependency( # noqa: E501
def test_installer_required_extras_should_not_be_removed_when_updating_single_dependency(
installer: Installer,
locker: Locker,
repo: Repository,
Expand Down Expand Up @@ -1948,7 +1948,7 @@ def test_installer_required_extras_should_not_be_removed_when_updating_single_de
assert installer.executor.removals_count == 0


def test_installer_required_extras_should_not_be_removed_when_updating_single_dependency_pypi_repository( # noqa: E501
def test_installer_required_extras_should_not_be_removed_when_updating_single_dependency_pypi_repository(
locker: Locker,
repo: Repository,
package: ProjectPackage,
Expand Down
2 changes: 1 addition & 1 deletion tests/masonry/builders/test_editable_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

if TYPE_CHECKING:
from pytest_mock import MockerFixture
from tests.types import FixtureDirGetter

from poetry.poetry import Poetry
from tests.types import FixtureDirGetter


@pytest.fixture()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def test_it_provides_the_correct_solution() -> None:
For foo, a possible solution would be to set the `python` property to ">=3.6,<4.0"\
"""
links = [
"https://python-poetry.org/docs/dependency-specification/#python-restricted-dependencies", # noqa: E501
"https://python-poetry.org/docs/dependency-specification/#using-environment-markers", # noqa: E501
"https://python-poetry.org/docs/dependency-specification/#python-restricted-dependencies",
"https://python-poetry.org/docs/dependency-specification/#using-environment-markers",
]

assert title == solution.solution_title
Expand Down
2 changes: 1 addition & 1 deletion tests/packages/test_locker.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ def test_extras_dependencies_are_ordered(locker: Locker, root: ProjectPackage) -
assert content == expected


def test_locker_should_neither_emit_warnings_nor_raise_error_for_lower_compatible_versions( # noqa: E501
def test_locker_should_neither_emit_warnings_nor_raise_error_for_lower_compatible_versions(
locker: Locker, caplog: LogCaptureFixture
) -> None:
older_version = "1.1"
Expand Down
12 changes: 6 additions & 6 deletions tests/puzzle/test_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ def test_solver_with_dependency_in_both_main_and_dev_dependencies(
)


def test_solver_with_dependency_in_both_main_and_dev_dependencies_with_one_more_dependent( # noqa: E501
def test_solver_with_dependency_in_both_main_and_dev_dependencies_with_one_more_dependent(
solver: Solver, repo: Repository, package: ProjectPackage
) -> None:
package.add_dependency(Factory.create_dependency("A", "*"))
Expand Down Expand Up @@ -2258,7 +2258,7 @@ def test_solver_can_resolve_git_dependencies_with_ref(
assert op.package.source_resolved_reference.startswith("9cf87a2")


def test_solver_does_not_trigger_conflict_for_python_constraint_if_python_requirement_is_compatible( # noqa: E501
def test_solver_does_not_trigger_conflict_for_python_constraint_if_python_requirement_is_compatible(
solver: Solver, repo: Repository, package: ProjectPackage
) -> None:
set_package_python_versions(solver.provider, "~2.7 || ^3.4")
Expand All @@ -2276,7 +2276,7 @@ def test_solver_does_not_trigger_conflict_for_python_constraint_if_python_requir
check_solver_result(transaction, [{"job": "install", "package": package_a}])


def test_solver_does_not_trigger_conflict_for_python_constraint_if_python_requirement_is_compatible_multiple( # noqa: E501
def test_solver_does_not_trigger_conflict_for_python_constraint_if_python_requirement_is_compatible_multiple(
solver: Solver, repo: Repository, package: ProjectPackage
) -> None:
set_package_python_versions(solver.provider, "~2.7 || ^3.4")
Expand Down Expand Up @@ -2308,7 +2308,7 @@ def test_solver_does_not_trigger_conflict_for_python_constraint_if_python_requir
)


def test_solver_triggers_conflict_for_dependency_python_not_fully_compatible_with_package_python( # noqa: E501
def test_solver_triggers_conflict_for_dependency_python_not_fully_compatible_with_package_python(
solver: Solver, repo: Repository, package: ProjectPackage
) -> None:
set_package_python_versions(solver.provider, "~2.7 || ^3.4")
Expand All @@ -2325,7 +2325,7 @@ def test_solver_triggers_conflict_for_dependency_python_not_fully_compatible_wit
solver.solve()


def test_solver_finds_compatible_package_for_dependency_python_not_fully_compatible_with_package_python( # noqa: E501
def test_solver_finds_compatible_package_for_dependency_python_not_fully_compatible_with_package_python(
solver: Solver, repo: Repository, package: ProjectPackage
) -> None:
set_package_python_versions(solver.provider, "~2.7 || ^3.4")
Expand All @@ -2347,7 +2347,7 @@ def test_solver_finds_compatible_package_for_dependency_python_not_fully_compati
check_solver_result(transaction, [{"job": "install", "package": package_a100}])


def test_solver_does_not_trigger_new_resolution_on_duplicate_dependencies_if_only_extras( # noqa: E501
def test_solver_does_not_trigger_new_resolution_on_duplicate_dependencies_if_only_extras(
solver: Solver, repo: Repository, package: ProjectPackage
) -> None:
dep1 = Dependency.create_from_pep_508('B (>=1.0); extra == "foo"')
Expand Down
Loading

0 comments on commit a949a6b

Please sign in to comment.