Skip to content
This repository was archived by the owner on Mar 1, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,36 @@ repos:
args: [--branch, main]
- id: trailing-whitespace
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0 # Use the ref you want to point at
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa
- id: python-check-mock-methods
- id: python-no-eval
- id: python-no-log-warn
- id: python-use-type-annotations
- id: text-unicode-replacement-char
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args: [--py37-plus]
- repo: https://github.com/asottile/reorder_python_imports
rev: v3.9.0
hooks:
- id: reorder-python-imports
args: [--py37-plus, --add-import, 'from __future__ import annotations']
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.1.0
hooks:
- id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.205
rev: v0.0.244
hooks:
- id: ruff
- repo: https://github.com/dosisod/refurb
rev: v1.9.1
rev: v1.12.0
hooks:
- id: refurb
args: [--ignore, FURB126]
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.2.0
hooks:
- id: setup-cfg-fmt
- repo: https://github.com/PyCQA/docformatter
rev: v1.5.1
hooks:
- id: docformatter
args: [--in-place, --wrap-summaries, "88", --wrap-descriptions, "88", --blank]
- repo: https://github.com/econchick/interrogate
rev: 1.5.0
hooks:
Expand All @@ -77,6 +67,20 @@ repos:
- id: codespell
args: [-L als, -L unparseable]
additional_dependencies: ["tomli"]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.0.0'
hooks:
- id: mypy
args: [
--no-strict-optional,
--ignore-missing-imports,
]
additional_dependencies: [
attrs>=21.3.0,
click,
types-setuptools
]
pass_filenames: false
- repo: https://github.com/mgedmin/check-manifest
rev: "0.49"
hooks:
Expand Down
26 changes: 24 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,29 @@ build-backend = "setuptools.build_meta"
write_to = "src/pytask_environment/_version.py"


[tool.mypy]
files = ["src", "tests"]
check_untyped_defs = true
disallow_any_generics = true
disallow_incomplete_defs = true
disallow_untyped_defs = true
no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true


[[tool.mypy.overrides]]
module = "tests.*"
disallow_untyped_defs = false
ignore_errors = true


[tool.codespell]
ignore-words-list = "falsy"


[tool.ruff]
target-version = "py37"
select = ["ALL"]
fix = true
extend-ignore = [
Expand All @@ -37,9 +55,13 @@ extend-ignore = [
"EM", # flake8-errmsg
"ANN401", # flake8-annotate typing.Any
"PD", # pandas-vet
"UP", # pyupgrade is too aggressive for py<3.10
"COM812", # trailing comma missing, but black takes care of that
"D401", # imperative mood for first line. too many false-positives.
# Temporarily ignored.
"TCH002",
]


[tool.ruff.per-file-ignores]
"tests/*" = ["D", "ANN"]
"tests/*" = ["D", "ANN", "PLR0913"]
"__init__.py" = ["D104"]
10 changes: 5 additions & 5 deletions src/pytask_environment/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,24 +68,24 @@ def pytask_log_session_header(session: Session) -> None:
pass
else:
console.print()
raise Exception(msg + "\n\n" + _ERROR_MSG) from None
raise Exception(msg + "\n\n" + _ERROR_MSG) from None # noqa: TRY002


@orm.db_session
def retrieve_package(name: str) -> str:
def retrieve_package(name: str) -> str | None:
"""Return booleans indicating whether the version or path of a package changed."""
try:
package = Environment[name]
package = Environment[name] # type: ignore[type-arg, valid-type]
except orm.ObjectNotFound:
package = None
package = None # type: ignore[misc]
return package


@orm.db_session
def create_or_update_state(name: str, version: str, path: str) -> None:
"""Create or update a state."""
try:
package_in_db = Environment[name]
package_in_db = Environment[name] # type: ignore[type-arg, valid-type]
except orm.ObjectNotFound:
Environment(name=name, version=version, path=path)
else:
Expand Down
Empty file added tests/__init__.py
Empty file.
16 changes: 10 additions & 6 deletions tests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from _pytask.database_utils import db


@pytest.mark.end_to_end
@pytest.mark.end_to_end()
def test_existence_of_python_executable_in_db(tmp_path, runner):
"""Test that the Python executable is stored in the database."""
task_path = tmp_path.joinpath("task_dummy.py")
Expand All @@ -38,7 +38,7 @@ def test_existence_of_python_executable_in_db(tmp_path, runner):
orm.delete(e for e in entity)


@pytest.mark.end_to_end
@pytest.mark.end_to_end()
def test_flow_when_python_version_has_changed(monkeypatch, tmp_path, runner):
"""Test the whole use-case.

Expand Down Expand Up @@ -96,8 +96,10 @@ def test_flow_when_python_version_has_changed(monkeypatch, tmp_path, runner):
orm.delete(e for e in entity)


@pytest.mark.end_to_end
@pytest.mark.parametrize("check_python_version, expected", [("true", 1), ("false", 0)])
@pytest.mark.end_to_end()
@pytest.mark.parametrize(
("check_python_version", "expected"), [("true", 1), ("false", 0)]
)
def test_python_version_changed(
monkeypatch, tmp_path, runner, check_python_version, expected
):
Expand Down Expand Up @@ -129,8 +131,10 @@ def test_python_version_changed(
orm.delete(e for e in entity)


@pytest.mark.end_to_end
@pytest.mark.parametrize("check_python_version, expected", [("true", 1), ("false", 0)])
@pytest.mark.end_to_end()
@pytest.mark.parametrize(
("check_python_version", "expected"), [("true", 1), ("false", 0)]
)
def test_environment_changed(
monkeypatch, tmp_path, runner, check_python_version, expected
):
Expand Down