Skip to content

Commit ca807db

Browse files
Add ruff and refurb to pre-commit and fix the CI banner. (#17)
1 parent 1ecd77a commit ca807db

File tree

10 files changed

+74
-43
lines changed

10 files changed

+74
-43
lines changed

.pre-commit-config.yaml

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.2.0
3+
rev: v4.4.0
44
hooks:
55
- id: check-added-large-files
66
args: ['--maxkb=100']
@@ -26,46 +26,34 @@ repos:
2626
- id: python-use-type-annotations
2727
- id: text-unicode-replacement-char
2828
- repo: https://github.com/asottile/pyupgrade
29-
rev: v2.32.0
29+
rev: v3.3.1
3030
hooks:
3131
- id: pyupgrade
3232
args: [--py37-plus]
3333
- repo: https://github.com/asottile/reorder_python_imports
34-
rev: v3.0.1
34+
rev: v3.9.0
3535
hooks:
3636
- id: reorder-python-imports
3737
args: [--py37-plus, --add-import, 'from __future__ import annotations']
3838
- repo: https://github.com/psf/black
39-
rev: 22.3.0
39+
rev: 22.12.0
4040
hooks:
4141
- id: black
42-
- repo: https://github.com/PyCQA/flake8
43-
rev: 4.0.1
42+
- repo: https://github.com/charliermarsh/ruff-pre-commit
43+
rev: v0.0.205
4444
hooks:
45-
- id: flake8
46-
types: [python]
47-
additional_dependencies: [
48-
flake8-alfred,
49-
flake8-bugbear,
50-
flake8-builtins,
51-
flake8-comprehensions,
52-
flake8-docstrings,
53-
flake8-eradicate,
54-
flake8-print,
55-
flake8-pytest-style,
56-
flake8-todo,
57-
flake8-typing-imports,
58-
flake8-unused-arguments,
59-
pep8-naming,
60-
pydocstyle,
61-
Pygments,
62-
]
45+
- id: ruff
46+
- repo: https://github.com/dosisod/refurb
47+
rev: v1.9.1
48+
hooks:
49+
- id: refurb
50+
args: [--ignore, FURB126]
6351
- repo: https://github.com/asottile/setup-cfg-fmt
64-
rev: v1.20.1
52+
rev: v2.2.0
6553
hooks:
6654
- id: setup-cfg-fmt
67-
- repo: https://github.com/myint/docformatter
68-
rev: v1.3.1
55+
- repo: https://github.com/PyCQA/docformatter
56+
rev: v1.5.1
6957
hooks:
7058
- id: docformatter
7159
args: [--in-place, --wrap-summaries, "88", --wrap-descriptions, "88", --blank]
@@ -75,7 +63,7 @@ repos:
7563
- id: interrogate
7664
args: [-v, --fail-under=40, src, tests]
7765
- repo: https://github.com/executablebooks/mdformat
78-
rev: 0.7.14
66+
rev: 0.7.16
7967
hooks:
8068
- id: mdformat
8169
additional_dependencies: [
@@ -84,12 +72,13 @@ repos:
8472
]
8573
args: [--wrap, "88"]
8674
- repo: https://github.com/codespell-project/codespell
87-
rev: v2.1.0
75+
rev: v2.2.2
8876
hooks:
8977
- id: codespell
9078
args: [-L als, -L unparseable]
79+
additional_dependencies: ["tomli"]
9180
- repo: https://github.com/mgedmin/check-manifest
92-
rev: "0.48"
81+
rev: "0.49"
9382
hooks:
9483
- id: check-manifest
9584
args: [--no-build-isolation]

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ reverse chronological order. Releases follow [semantic versioning](https://semve
55
and all releases are available on
66
[Anaconda.org](https://anaconda.org/conda-forge/pytask-environment).
77

8+
## 0.2.x - 2023-xx-xx
9+
10+
- {pull}`17` adds ruff and refurb to pre-commits and fixes the banner.
11+
812
## 0.2.0 - 2022-16-04
913

1014
- {pull}`15` aligns pytask-environment with pytask v0.2.0.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![image](https://img.shields.io/conda/vn/conda-forge/pytask-environment.svg)](https://anaconda.org/conda-forge/pytask-environment)
66
[![image](https://img.shields.io/conda/pn/conda-forge/pytask-environment.svg)](https://anaconda.org/conda-forge/pytask-environment)
77
[![PyPI - License](https://img.shields.io/pypi/l/pytask-environment)](https://pypi.org/project/pytask-environment)
8-
[![image](https://img.shields.io/github/workflow/status/pytask-dev/pytask-environment/Continuous%20Integration%20Workflow/main)](https://github.com/pytask-dev/pytask-environment/actions?query=branch%3Amain)
8+
[![image](https://img.shields.io/github/actions/workflow/status/pytask-dev/pytask-environment/main.yml?branch=main)](https://github.com/pytask-dev/pytask-environment/actions?query=branch%3Amain)
99
[![image](https://codecov.io/gh/pytask-dev/pytask-environment/branch/main/graph/badge.svg)](https://codecov.io/gh/pytask-dev/pytask-environment)
1010
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/pytask-dev/pytask-environment/main.svg)](https://results.pre-commit.ci/latest/github/pytask-dev/pytask-environment/main)
1111
[![image](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ channels:
55
- nodefaults
66

77
dependencies:
8-
- python >=3.6
8+
- python >=3.7
99
- pip
1010
- setuptools_scm
1111
- toml

pyproject.toml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,41 @@ build-backend = "setuptools.build_meta"
55

66
[tool.setuptools_scm]
77
write_to = "src/pytask_environment/_version.py"
8+
9+
10+
[tool.codespell]
11+
ignore-words-list = "falsy"
12+
13+
14+
[tool.ruff]
15+
select = ["ALL"]
16+
fix = true
17+
extend-ignore = [
18+
# Numpy docstyle
19+
"D107",
20+
"D203",
21+
"D212",
22+
"D213",
23+
"D402",
24+
"D404",
25+
"D413",
26+
"D415",
27+
"D416",
28+
"D417",
29+
# Others.
30+
"RET504", # unnecessary variable assignment before return.
31+
"S101", # raise errors for asserts.
32+
"B905", # strict parameter for zip that was implemented in py310.
33+
"I", # ignore isort
34+
"ANN101", # type annotating self
35+
"ANN102", # type annotating cls
36+
"FBT", # flake8-boolean-trap
37+
"EM", # flake8-errmsg
38+
"ANN401", # flake8-annotate typing.Any
39+
"PD", # pandas-vet
40+
"UP", # pyupgrade is too aggressive for py<3.10
41+
]
42+
43+
44+
[tool.ruff.per-file-ignores]
45+
"tests/*" = ["D", "ANN"]

setup.cfg

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ classifiers =
1515
Operating System :: OS Independent
1616
Programming Language :: Python :: 3
1717
Programming Language :: Python :: 3 :: Only
18-
Programming Language :: Python :: 3.7
19-
Programming Language :: Python :: 3.8
20-
Programming Language :: Python :: 3.9
21-
Programming Language :: Python :: 3.10
2218
project_urls =
2319
Changelog = https://github.com/pytask-dev/pytask-environment/blob/main/CHANGES.md
2420
Documentation = https://github.com/pytask-dev/pytask-environment

src/pytask_environment/config.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""This module contains everything related to the configuration."""
12
from __future__ import annotations
23

34
from typing import Any
@@ -61,18 +62,18 @@ def _get_first_non_none_value(
6162
the order of the inputs while also providing a default.
6263
6364
"""
64-
callback = (lambda x: x) if callback is None else callback # noqa: E731
65+
callback = (lambda x: x) if callback is None else callback
6566
processed_values = (callback(config.get(key)) for config in configs)
6667
return next((value for value in processed_values if value is not None), default)
6768

6869

6970
def _convert_truthy_or_falsy_to_bool(x: bool | str | None) -> bool:
7071
"""Convert truthy or falsy value in .ini to Python boolean."""
71-
if x in [True, "True", "true", "1"]:
72+
if x in (True, "True", "true", "1"):
7273
out = True
73-
elif x in [False, "False", "false", "0"]:
74+
elif x in (False, "False", "false", "0"):
7475
out = False
75-
elif x in [None, "None", "none"]:
76+
elif x in (None, "None", "none"):
7677
out = None
7778
else:
7879
raise ValueError(

src/pytask_environment/database.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""This module contains everything related to the database."""
12
from __future__ import annotations
23

34
from pony import orm

src/pytask_environment/logging.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""This module contains everything related to logging."""
12
from __future__ import annotations
23

34
import sys
@@ -34,7 +35,7 @@ def pytask_log_session_header(session: Session) -> None:
3435
not session.config["check_python_version"]
3536
and not session.config["check_environment"]
3637
):
37-
return None
38+
return
3839

3940
package = retrieve_package("python")
4041

@@ -43,7 +44,7 @@ def pytask_log_session_header(session: Session) -> None:
4344

4445
# Bail out if everything is fine.
4546
if same_version and same_path:
46-
return None
47+
return
4748

4849
msg = ""
4950
if not same_version and session.config["check_python_version"]:

src/pytask_environment/plugin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
"""Entry-point for the plugin."""
22
from __future__ import annotations
33

4+
from pluggy import PluginManager
45
from pytask import hookimpl
56
from pytask_environment import config
67
from pytask_environment import database
78
from pytask_environment import logging
89

910

1011
@hookimpl
11-
def pytask_add_hooks(pm):
12+
def pytask_add_hooks(pm: PluginManager) -> None:
1213
"""Register some plugins."""
1314
pm.register(logging)
1415
pm.register(config)

0 commit comments

Comments
 (0)