From abfd5e1aab34fc3fdebb17ad9d6ad07272db7988 Mon Sep 17 00:00:00 2001
From: Tomas Perez Alvarez <72174660+Tomperez98@users.noreply.github.com>
Date: Wed, 20 Dec 2023 19:17:10 -0500
Subject: [PATCH] Lock command. Upgrades dependencies (#27)
---
.whitelist.vulture | 1 -
pyproject.toml | 28 ++++----
pyrgo/cli/{_main.py => __main__.py} | 0
pyrgo/cli/cmds/lock.py | 17 ++++-
pyrgo/core/_conf.py | 17 +----
.../new-project/new_project/__init__.py | 1 +
.../core/resources/new-project/pyproject.toml | 36 +---------
requirements/core.txt | 69 ++++++++++---------
requirements/dev.txt | 58 +++++++++-------
9 files changed, 103 insertions(+), 124 deletions(-)
rename pyrgo/cli/{_main.py => __main__.py} (100%)
diff --git a/.whitelist.vulture b/.whitelist.vulture
index 8dc5ff6..e69de29 100644
--- a/.whitelist.vulture
+++ b/.whitelist.vulture
@@ -1 +0,0 @@
-NAME # unused variable (pyrgo/cli/cmds/check.py:102)
diff --git a/pyproject.toml b/pyproject.toml
index f795c97..7f154a3 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "pyrgo"
-version = "2.0.0"
+version = "2.1.0"
readme = "README.md"
requires-python = ">=3.9"
classifiers = [
@@ -16,25 +16,24 @@ authors = [
{ name = "Tomas Perez Alvarez", email = "tomasperezalvarez@gmail.com" },
]
dependencies = [
- "click",
- "ruff>=0.1.2",
- "mypy",
- "pip-tools>=7.0.0",
- "pytest",
- "result",
- "build",
- "loguru",
- "pip-audit>=2.5.5",
+ "click < 9",
+ "ruff < 1",
+ "mypy < 2",
+ "pip-tools < 8",
+ "pytest < 8",
+ "result < 1",
+ "build < 2",
+ "pip-audit < 3",
"vulture < 3",
- "tomli",
+ "tomli < 3",
"pdoc < 15",
]
[project.optional-dependencies]
-dev = ["pytest-cov"]
+dev = ["pytest-cov < 5"]
[project.scripts]
-pyrgo = "pyrgo.cli._main:cli"
+pyrgo = "pyrgo.cli.__main__:cli"
[project.urls]
Documentation = "https://github.com/Tomperez98/pyrgo#readme"
@@ -42,6 +41,7 @@ Issues = "https://github.com/Tomperez98/pyrgo/issues"
Source = "https://github.com/Tomperez98/pyrgo"
[tool.ruff]
+logger-objects = ["pyrgo.logging.logger"]
line-length = 88
ignore = [
"ANN101",
@@ -121,14 +121,12 @@ precision = 1
exclude_lines = ["if TYPE_CHECKING:", "raise NotImplementedError"]
[tool.mypy]
-show_error_codes = true
follow_imports = "normal"
strict_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
disallow_any_generics = true
check_untyped_defs = true
-no_implicit_reexport = true
warn_unused_configs = true
disallow_subclassing_any = true
disallow_incomplete_defs = true
diff --git a/pyrgo/cli/_main.py b/pyrgo/cli/__main__.py
similarity index 100%
rename from pyrgo/cli/_main.py
rename to pyrgo/cli/__main__.py
diff --git a/pyrgo/cli/cmds/lock.py b/pyrgo/cli/cmds/lock.py
index 51a942e..323fa0b 100644
--- a/pyrgo/cli/cmds/lock.py
+++ b/pyrgo/cli/cmds/lock.py
@@ -15,8 +15,11 @@
import subprocess
-def _initial_args(env: str, core_deps_alias: str) -> list[str]:
+def _initial_args(env: str, core_deps_alias: str, *, upgrade: bool) -> list[str]:
base_args = ["compile"]
+ if upgrade:
+ base_args.append("-U")
+
if env == core_deps_alias:
return base_args
@@ -56,6 +59,14 @@ def _complete_cmd(
show_default=True,
type=click.BOOL,
)
+@click.option(
+ "--upgrade",
+ "upgrade",
+ is_flag=True,
+ default=False,
+ show_default=True,
+ type=click.BOOL,
+)
@click.option(
"-e",
"--env",
@@ -64,7 +75,7 @@ def _complete_cmd(
type=click.STRING,
required=False,
)
-def lock(*, generate_hashes: bool, envs: tuple[str, ...]) -> None:
+def lock(*, generate_hashes: bool, envs: tuple[str, ...], upgrade: bool) -> None:
"""Lock project dependencies with `piptools`."""
configuration = PyrgoConf.new()
@@ -85,6 +96,7 @@ def lock(*, generate_hashes: bool, envs: tuple[str, ...]) -> None:
args=_initial_args(
env=env,
core_deps_alias=configuration.core_deps_alias,
+ upgrade=upgrade,
),
),
generate_hashes=generate_hashes,
@@ -107,6 +119,7 @@ def lock(*, generate_hashes: bool, envs: tuple[str, ...]) -> None:
args=_initial_args(
env=env,
core_deps_alias=configuration.core_deps_alias,
+ upgrade=upgrade,
),
),
generate_hashes=generate_hashes,
diff --git a/pyrgo/core/_conf.py b/pyrgo/core/_conf.py
index 11e19d6..36a7e53 100644
--- a/pyrgo/core/_conf.py
+++ b/pyrgo/core/_conf.py
@@ -2,11 +2,9 @@
from __future__ import annotations
import pathlib
-import sys
from dataclasses import dataclass
from typing import Any
-import loguru
import tomli
@@ -17,20 +15,12 @@ def __init__(self, path: pathlib.Path) -> None:
super().__init__(f"`pyproject.toml` not found at {path.as_posix()}")
-def _configure_logger(logger: loguru.Logger) -> loguru.Logger:
- logger.remove()
- fmt = "[{level}] {message} {name}:{function}:{line} @ {time:HH:mm:ss}"
- logger.add(sys.stderr, format=fmt)
- return logger
-
-
@dataclass(frozen=True)
class PyrgoConf:
"""Pyrgo configuration."""
cwd: pathlib.Path
requirements: pathlib.Path
- logger: loguru.Logger
relevant_paths: list[str]
artifacts: list[pathlib.Path]
caches: list[pathlib.Path]
@@ -41,7 +31,6 @@ class PyrgoConf:
@classmethod
def new(cls: type[PyrgoConf]) -> PyrgoConf:
"""Create new configuration instance."""
- logger = _configure_logger(logger=loguru.logger)
cwd = pathlib.Path().cwd()
pyproject_path = cwd.joinpath("pyproject.toml")
if not (pyproject_path.exists() and pyproject_path.is_file()):
@@ -52,10 +41,11 @@ def new(cls: type[PyrgoConf]) -> PyrgoConf:
relevant_paths: list[str] = [
project_name,
]
+ pyproject_tooling: dict[str, Any] = pyproject_data["tool"]
relevant_paths.extend(
- pyproject_data["tool"]["pytest"]["ini_options"]["testpaths"],
+ pyproject_tooling["pytest"]["ini_options"]["testpaths"],
)
- pyrgo_config = pyproject_data["tool"].get("pyrgo", None)
+ pyrgo_config: dict[str, Any] | None = pyproject_tooling.get("pyrgo", None)
caches = [
cwd.joinpath(".pytest_cache"),
cwd.joinpath(".ruff_cache"),
@@ -81,7 +71,6 @@ def new(cls: type[PyrgoConf]) -> PyrgoConf:
return cls(
cwd=cwd,
requirements=cwd.joinpath("requirements"),
- logger=logger,
relevant_paths=relevant_paths,
artifacts=[cwd.joinpath("dist")],
caches=caches,
diff --git a/pyrgo/core/resources/new-project/new_project/__init__.py b/pyrgo/core/resources/new-project/new_project/__init__.py
index e69de29..a7eca95 100644
--- a/pyrgo/core/resources/new-project/new_project/__init__.py
+++ b/pyrgo/core/resources/new-project/new_project/__init__.py
@@ -0,0 +1 @@
+"""Project code."""
diff --git a/pyrgo/core/resources/new-project/pyproject.toml b/pyrgo/core/resources/new-project/pyproject.toml
index 68f7299..142a58e 100644
--- a/pyrgo/core/resources/new-project/pyproject.toml
+++ b/pyrgo/core/resources/new-project/pyproject.toml
@@ -15,7 +15,7 @@ authors = [{ name = "Author name", email = "author@email.com" }]
dependencies = []
[project.optional-dependencies]
-dev = ["pyrgo"]
+dev = ["pyrgo < 3"]
[tool.ruff]
line-length = 88
@@ -59,55 +59,21 @@ exclude = [
]
[tool.ruff.per-file-ignores]
-"scripts/*.py" = ["INP001"]
-"__init__.py" = ["D104"]
"tests/*.py" = ["INP001", "S101", "D"]
-[tool.ruff.isort]
-known-first-party = ["pyrgo"]
-force-wrap-aliases = false
-combine-as-imports = true
-required-imports = ["from __future__ import annotations"]
-
-[tool.ruff.flake8-tidy-imports]
-ban-relative-imports = "all"
-
-[tool.ruff.flake8-quotes]
-inline-quotes = "double"
-
-[tool.black]
-line-length = 88
-include = '\.pyi?$'
-
[tool.pytest.ini_options]
testpaths = ["tests"]
xfail_strict = true
addopts = ["--import-mode=importlib", "--strict-markers"]
markers = ["integration: mark integration tests.", "unit: mark unittest."]
-[tool.coverage.run]
-branch = true
-parallel = true
-relative_files = true
-
-[tool.coverage.report]
-precision = 1
-exclude_lines = [
- "if __name__ == .__main__.:",
- "if TYPE_CHECKING:",
- "@overload",
- "raise NotImplementedError",
-]
-
[tool.mypy]
-show_error_codes = true
follow_imports = "normal"
strict_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
disallow_any_generics = true
check_untyped_defs = true
-no_implicit_reexport = true
warn_unused_configs = true
disallow_subclassing_any = true
disallow_incomplete_defs = true
diff --git a/requirements/core.txt b/requirements/core.txt
index 9de89e8..aa083f0 100644
--- a/requirements/core.txt
+++ b/requirements/core.txt
@@ -4,7 +4,9 @@
#
# pip-compile --output-file=requirements/core.txt pyproject.toml
#
-build==0.10.0
+boolean-py==4.0
+ # via license-expression
+build==1.0.3
# via
# pip-tools
# pyrgo (pyproject.toml)
@@ -12,31 +14,35 @@ cachecontrol[filecache]==0.13.1
# via
# cachecontrol
# pip-audit
-certifi==2023.5.7
+certifi==2023.11.17
# via requests
-charset-normalizer==3.1.0
+charset-normalizer==3.3.2
# via requests
-click==8.1.3
+click==8.1.7
# via
# pip-tools
# pyrgo (pyproject.toml)
-cyclonedx-python-lib==2.7.1
+cyclonedx-python-lib==5.2.0
# via pip-audit
-exceptiongroup==1.1.1
+defusedxml==0.7.1
+ # via py-serializable
+exceptiongroup==1.2.0
# via pytest
-filelock==3.12.0
+filelock==3.13.1
# via cachecontrol
html5lib==1.1
# via pip-audit
-idna==3.4
+idna==3.6
# via requests
+importlib-metadata==7.0.0
+ # via build
iniconfig==2.0.0
# via pytest
jinja2==3.1.2
# via pdoc
-loguru==0.7.0
- # via pyrgo (pyproject.toml)
-markdown-it-py==2.2.0
+license-expression==30.2.0
+ # via cyclonedx-python-lib
+markdown-it-py==3.0.0
# via rich
markupsafe==2.1.3
# via
@@ -44,51 +50,53 @@ markupsafe==2.1.3
# pdoc
mdurl==0.1.2
# via markdown-it-py
-msgpack==1.0.5
+msgpack==1.0.7
# via cachecontrol
-mypy==1.3.0
+mypy==1.7.1
# via pyrgo (pyproject.toml)
mypy-extensions==1.0.0
# via mypy
-packageurl-python==0.11.1
+packageurl-python==0.13.1
# via cyclonedx-python-lib
-packaging==23.1
+packaging==23.2
# via
# build
# pip-audit
# pip-requirements-parser
# pytest
-pdoc==14.1.0
+pdoc==14.2.0
# via pyrgo (pyproject.toml)
pip-api==0.0.30
# via pip-audit
-pip-audit==2.5.6
+pip-audit==2.6.2
# via pyrgo (pyproject.toml)
pip-requirements-parser==32.0.1
# via pip-audit
pip-tools==7.3.0
# via pyrgo (pyproject.toml)
-pluggy==1.0.0
+pluggy==1.3.0
# via pytest
-pygments==2.15.1
+py-serializable==0.15.0
+ # via cyclonedx-python-lib
+pygments==2.17.2
# via
# pdoc
# rich
-pyparsing==3.0.9
+pyparsing==3.1.1
# via pip-requirements-parser
pyproject-hooks==1.0.0
# via build
-pytest==7.3.1
+pytest==7.4.3
# via pyrgo (pyproject.toml)
requests==2.31.0
# via
# cachecontrol
# pip-audit
-result==0.10.0
+result==0.15.0
# via pyrgo (pyproject.toml)
-rich==13.4.1
+rich==13.7.0
# via pip-audit
-ruff==0.1.2
+ruff==0.1.8
# via pyrgo (pyproject.toml)
six==1.16.0
# via html5lib
@@ -96,7 +104,6 @@ sortedcontainers==2.4.0
# via cyclonedx-python-lib
toml==0.10.2
# via
- # cyclonedx-python-lib
# pip-audit
# vulture
tomli==2.0.1
@@ -107,20 +114,20 @@ tomli==2.0.1
# pyproject-hooks
# pyrgo (pyproject.toml)
# pytest
-typing-extensions==4.6.3
+typing-extensions==4.9.0
# via
# mypy
# result
-urllib3==1.26.16
- # via
- # pip-audit
- # requests
+urllib3==2.1.0
+ # via requests
vulture==2.10
# via pyrgo (pyproject.toml)
webencodings==0.5.1
# via html5lib
-wheel==0.40.0
+wheel==0.42.0
# via pip-tools
+zipp==3.17.0
+ # via importlib-metadata
# The following packages are considered to be unsafe in a requirements file:
# pip
diff --git a/requirements/dev.txt b/requirements/dev.txt
index eca6cb3..e5c0d4a 100644
--- a/requirements/dev.txt
+++ b/requirements/dev.txt
@@ -4,7 +4,9 @@
#
# pip-compile --extra=dev --output-file=requirements/dev.txt pyproject.toml
#
-build==0.10.0
+boolean-py==4.0
+ # via license-expression
+build==1.0.3
# via
# pip-tools
# pyrgo (pyproject.toml)
@@ -12,36 +14,38 @@ cachecontrol[filecache]==0.13.1
# via
# cachecontrol
# pip-audit
-certifi==2023.7.22
+certifi==2023.11.17
# via requests
-charset-normalizer==3.2.0
+charset-normalizer==3.3.2
# via requests
click==8.1.7
# via
# pip-tools
# pyrgo (pyproject.toml)
-coverage[toml]==7.3.0
+coverage[toml]==7.3.4
# via
# coverage
# pytest-cov
-cyclonedx-python-lib==4.0.1
+cyclonedx-python-lib==5.2.0
# via pip-audit
defusedxml==0.7.1
# via py-serializable
-exceptiongroup==1.1.3
+exceptiongroup==1.2.0
# via pytest
-filelock==3.12.2
+filelock==3.13.1
# via cachecontrol
html5lib==1.1
# via pip-audit
-idna==3.4
+idna==3.6
# via requests
+importlib-metadata==7.0.0
+ # via build
iniconfig==2.0.0
# via pytest
jinja2==3.1.2
# via pdoc
-loguru==0.7.0
- # via pyrgo (pyproject.toml)
+license-expression==30.2.0
+ # via cyclonedx-python-lib
markdown-it-py==3.0.0
# via rich
markupsafe==2.1.3
@@ -50,35 +54,35 @@ markupsafe==2.1.3
# pdoc
mdurl==0.1.2
# via markdown-it-py
-msgpack==1.0.5
+msgpack==1.0.7
# via cachecontrol
-mypy==1.5.1
+mypy==1.7.1
# via pyrgo (pyproject.toml)
mypy-extensions==1.0.0
# via mypy
-packageurl-python==0.11.2
+packageurl-python==0.13.1
# via cyclonedx-python-lib
-packaging==23.1
+packaging==23.2
# via
# build
# pip-audit
# pip-requirements-parser
# pytest
-pdoc==14.1.0
+pdoc==14.2.0
# via pyrgo (pyproject.toml)
pip-api==0.0.30
# via pip-audit
-pip-audit==2.6.1
+pip-audit==2.6.2
# via pyrgo (pyproject.toml)
pip-requirements-parser==32.0.1
# via pip-audit
pip-tools==7.3.0
# via pyrgo (pyproject.toml)
-pluggy==1.2.0
+pluggy==1.3.0
# via pytest
-py-serializable==0.11.1
+py-serializable==0.15.0
# via cyclonedx-python-lib
-pygments==2.16.1
+pygments==2.17.2
# via
# pdoc
# rich
@@ -86,7 +90,7 @@ pyparsing==3.1.1
# via pip-requirements-parser
pyproject-hooks==1.0.0
# via build
-pytest==7.4.0
+pytest==7.4.3
# via
# pyrgo (pyproject.toml)
# pytest-cov
@@ -96,11 +100,11 @@ requests==2.31.0
# via
# cachecontrol
# pip-audit
-result==0.13.1
+result==0.15.0
# via pyrgo (pyproject.toml)
-rich==13.5.2
+rich==13.7.0
# via pip-audit
-ruff==0.1.2
+ruff==0.1.8
# via pyrgo (pyproject.toml)
six==1.16.0
# via html5lib
@@ -119,18 +123,20 @@ tomli==2.0.1
# pyproject-hooks
# pyrgo (pyproject.toml)
# pytest
-typing-extensions==4.7.1
+typing-extensions==4.9.0
# via
# mypy
# result
-urllib3==2.0.4
+urllib3==2.1.0
# via requests
vulture==2.10
# via pyrgo (pyproject.toml)
webencodings==0.5.1
# via html5lib
-wheel==0.41.1
+wheel==0.42.0
# via pip-tools
+zipp==3.17.0
+ # via importlib-metadata
# The following packages are considered to be unsafe in a requirements file:
# pip