Skip to content

Commit

Permalink
build: add support for python 3.10 (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
apoclyps authored Dec 5, 2023
1 parent 2ed9302 commit d5264da
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 119 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ repos:
- id: forbid-new-submodules
- id: mixed-line-ending
args: ["--fix=lf"]
description: Forces to replace line ending by the UNIX 'lf' character.
description: Forces to replace line ending by the UNIX "lf" character.
- id: check-added-large-files
args: ["--maxkb=500"]
- id: no-commit-to-branch
Expand All @@ -57,7 +57,7 @@ repos:
files: ^tests/app/

- repo: https://github.com/ambv/black
rev: 23.10.1
rev: 23.11.0
hooks:
- id: black

Expand Down Expand Up @@ -99,17 +99,17 @@ repos:
- tomli

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.1.4
rev: v0.1.7
hooks:
- id: ruff

- repo: https://github.com/dosisod/refurb
rev: v1.22.1
rev: v1.24.0
hooks:
- id: refurb

- repo: https://github.com/commitizen-tools/commitizen
rev: 3.12.0
rev: v3.13.0
hooks:
- id: commitizen
stages:
Expand Down
218 changes: 128 additions & 90 deletions poetry.lock

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ classifiers = [
include = ["LICENSE.md"]

[tool.poetry.dependencies]
python = "^3.11"
python = "^3.10"
poetry = "^1.6.1"

[tool.poetry.group.dev.dependencies]
black = "23.9.1"
codespell = "2.2.5"
freezegun = "1.2.2"
black = "23.11.0"
codespell = "2.2.6"
freezegun = "1.3.1"
ipdb = "0.13.13"
mypy = "1.5.1"
mypy = "1.7.1"
pre-commit = "3.5.0"
pytest = "7.4.2"
pytest = "7.4.3"
pytest-cov = "4.1.0"
pytest-mock = "3.12.0"
refurb = "1.21.0"
ruff = "0.0.291"
refurb = "1.24.0"
ruff = "0.1.7"
vcrpy = "5.1.0"

[tool.poetry.plugins."poetry.application.plugin"]
Expand All @@ -43,7 +43,7 @@ requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.black]
line_length = 120
line_length = 88

[tool.mypy]
ignore_missing_imports = true
Expand Down Expand Up @@ -159,7 +159,7 @@ exclude = [
"tests/test_migrations.py",
]

line-length = 120
line-length = 88

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
Expand Down
31 changes: 23 additions & 8 deletions src/poetry_plugin_upgrade/command.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections.abc import Iterable
from http import HTTPStatus
from typing import Any, Self
from typing import Any

import requests
from cleo.helpers import argument, option
Expand Down Expand Up @@ -36,7 +36,9 @@ class UpgradeCommand(InstallerCommand):
option(
long_name="pinned",
short_name=None,
description=("Include pinned (exact) dependencies when updating to latest."),
description=(
"Include pinned (exact) dependencies when updating to latest."
),
),
option(
long_name="exclude",
Expand All @@ -54,7 +56,8 @@ class UpgradeCommand(InstallerCommand):
option(
long_name="dry-run",
short_name=None,
description="Output bumped <comment>pyproject.toml</> but do not " "execute anything.",
description="Output bumped <comment>pyproject.toml</> but do not "
"execute anything.",
),
option(
long_name="preserve-wildcard",
Expand Down Expand Up @@ -142,7 +145,7 @@ def retrieve_latest_version(name: str) -> str:
return info["version"]

def handle_dependency(
self: Self,
self,
dependency: Dependency,
latest: bool,
pinned: bool,
Expand Down Expand Up @@ -180,7 +183,9 @@ def handle_dependency(
self.line(f"No new version for '{dependency.name}'")
return

new_version = self.handle_version(current_version=dependency.pretty_constraint, candidate=candidate)
new_version = self.handle_version(
current_version=dependency.pretty_constraint, candidate=candidate
)

self.bump_version_in_pyproject_content(
dependency=dependency,
Expand Down Expand Up @@ -212,7 +217,11 @@ def handle_version(current_version: str, candidate: Package) -> str:
if current_version.startswith("=="):
version_constraint = "=="

return f"{version_constraint}{candidate.pretty_version}" if version_constraint else candidate.pretty_version
return (
f"{version_constraint}{candidate.pretty_version}"
if version_constraint
else candidate.pretty_version
)

@staticmethod
def is_bumpable(
Expand Down Expand Up @@ -260,7 +269,9 @@ def bump_version_in_pyproject_content(
) -> None:
"""Bumps versions in pyproject content (pyproject.toml)"""

poetry_content: dict[str, Any] = pyproject_content.get("tool", {}).get("poetry", {})
poetry_content: dict[str, Any] = pyproject_content.get("tool", {}).get(
"poetry", {}
)

for group in dependency.groups:
# find section to modify
Expand All @@ -272,7 +283,11 @@ def bump_version_in_pyproject_content(
# take account for the old `dev-dependencies` section
section = poetry_content.get("dev-dependencies", {})
else:
section = poetry_content.get("group", {}).get(group, {}).get("dependencies", {})
section = (
poetry_content.get("group", {})
.get(group, {})
.get("dependencies", {})
)

# modify section
if isinstance(section.get(dependency.pretty_name), str):
Expand Down
4 changes: 1 addition & 3 deletions src/poetry_plugin_upgrade/plugin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Self

from poetry.plugins.application_plugin import ApplicationPlugin

import poetry_plugin_upgrade
Expand All @@ -11,5 +9,5 @@ def factory() -> UpgradeCommand:


class UpgradeApplicationPlugin(ApplicationPlugin):
def activate(self: Self, application: poetry_plugin_upgrade) -> None:
def activate(self, application: poetry_plugin_upgrade) -> None:
application.command_loader.register_factory("upgrade", factory)
4 changes: 3 additions & 1 deletion tests/e2e/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ def test_command_with_exclude(
path = project_path / "expected_pyproject_with_exclude.toml"
expected = PyProjectTOML(path).file.read()

assert app_tester.execute("upgrade --exclude foo --exclude bar --exclude=grault") == 0
assert (
app_tester.execute("upgrade --exclude foo --exclude bar --exclude=grault") == 0
)
assert PyProjectTOML(tmp_pyproject_path).file.read() == expected
command_call.assert_called_once_with(name="update")

Expand Down
4 changes: 3 additions & 1 deletion tests/unit/command/test_handle_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def test_handle_version(
version=available_version,
)

version = upgrade_cmd_tester.handle_version(current_version=current_version, candidate=candidate)
version = upgrade_cmd_tester.handle_version(
current_version=current_version, candidate=candidate
)

assert version == expected_version

0 comments on commit d5264da

Please sign in to comment.