From 4ac97fbd7de04d2a79ef82786259bd562d1da43d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 19 Dec 2022 19:57:01 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.2.0 → v4.4.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.2.0...v4.4.0) - [github.com/asottile/pyupgrade: v2.32.0 → v3.3.1](https://github.com/asottile/pyupgrade/compare/v2.32.0...v3.3.1) - [github.com/asottile/reorder_python_imports: v3.0.1 → v3.9.0](https://github.com/asottile/reorder_python_imports/compare/v3.0.1...v3.9.0) - [github.com/psf/black: 22.3.0 → 22.12.0](https://github.com/psf/black/compare/22.3.0...22.12.0) - [github.com/PyCQA/flake8: 4.0.1 → 6.0.0](https://github.com/PyCQA/flake8/compare/4.0.1...6.0.0) - [github.com/asottile/setup-cfg-fmt: v1.20.1 → v2.2.0](https://github.com/asottile/setup-cfg-fmt/compare/v1.20.1...v2.2.0) - https://github.com/myint/docformatter → https://github.com/PyCQA/docformatter - [github.com/PyCQA/docformatter: v1.3.1 → v1.5.1](https://github.com/PyCQA/docformatter/compare/v1.3.1...v1.5.1) - [github.com/executablebooks/mdformat: 0.7.14 → 0.7.16](https://github.com/executablebooks/mdformat/compare/0.7.14...0.7.16) - [github.com/codespell-project/codespell: v2.1.0 → v2.2.2](https://github.com/codespell-project/codespell/compare/v2.1.0...v2.2.2) - [github.com/mgedmin/check-manifest: 0.48 → 0.49](https://github.com/mgedmin/check-manifest/compare/0.48...0.49) --- .pre-commit-config.yaml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 10c6df6..f3f409b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.2.0 + rev: v4.4.0 hooks: - id: check-added-large-files args: ['--maxkb=100'] @@ -26,21 +26,21 @@ repos: - id: python-use-type-annotations - id: text-unicode-replacement-char - repo: https://github.com/asottile/pyupgrade - rev: v2.32.0 + rev: v3.3.1 hooks: - id: pyupgrade args: [--py37-plus] - repo: https://github.com/asottile/reorder_python_imports - rev: v3.0.1 + 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.3.0 + rev: 22.12.0 hooks: - id: black - repo: https://github.com/PyCQA/flake8 - rev: 4.0.1 + rev: 6.0.0 hooks: - id: flake8 types: [python] @@ -61,11 +61,11 @@ repos: Pygments, ] - repo: https://github.com/asottile/setup-cfg-fmt - rev: v1.20.1 + rev: v2.2.0 hooks: - id: setup-cfg-fmt -- repo: https://github.com/myint/docformatter - rev: v1.3.1 +- repo: https://github.com/PyCQA/docformatter + rev: v1.5.1 hooks: - id: docformatter args: [--in-place, --wrap-summaries, "88", --wrap-descriptions, "88", --blank] @@ -75,7 +75,7 @@ repos: - id: interrogate args: [-v, --fail-under=40, src, tests] - repo: https://github.com/executablebooks/mdformat - rev: 0.7.14 + rev: 0.7.16 hooks: - id: mdformat additional_dependencies: [ @@ -84,12 +84,12 @@ repos: ] args: [--wrap, "88"] - repo: https://github.com/codespell-project/codespell - rev: v2.1.0 + rev: v2.2.2 hooks: - id: codespell args: [-L als, -L unparseable] - repo: https://github.com/mgedmin/check-manifest - rev: "0.48" + rev: "0.49" hooks: - id: check-manifest args: [--no-build-isolation] From be4e7eabda7c2528949e04871a4fb7d665de64bf Mon Sep 17 00:00:00 2001 From: Tobias Raabe Date: Sun, 1 Jan 2023 17:41:56 +0100 Subject: [PATCH 2/2] Add new pre-commits. --- .pre-commit-config.yaml | 29 +++++++---------------- CHANGES.md | 4 ++++ README.md | 2 +- environment.yml | 2 +- pyproject.toml | 38 ++++++++++++++++++++++++++++++ setup.cfg | 4 ---- src/pytask_environment/config.py | 9 +++---- src/pytask_environment/database.py | 1 + src/pytask_environment/logging.py | 5 ++-- src/pytask_environment/plugin.py | 3 ++- 10 files changed, 64 insertions(+), 33 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f3f409b..7a65eaf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,27 +39,15 @@ repos: rev: 22.12.0 hooks: - id: black -- repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 +- repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.0.205 hooks: - - id: flake8 - types: [python] - additional_dependencies: [ - flake8-alfred, - flake8-bugbear, - flake8-builtins, - flake8-comprehensions, - flake8-docstrings, - flake8-eradicate, - flake8-print, - flake8-pytest-style, - flake8-todo, - flake8-typing-imports, - flake8-unused-arguments, - pep8-naming, - pydocstyle, - Pygments, - ] + - id: ruff +- repo: https://github.com/dosisod/refurb + rev: v1.9.1 + hooks: + - id: refurb + args: [--ignore, FURB126] - repo: https://github.com/asottile/setup-cfg-fmt rev: v2.2.0 hooks: @@ -88,6 +76,7 @@ repos: hooks: - id: codespell args: [-L als, -L unparseable] + additional_dependencies: ["tomli"] - repo: https://github.com/mgedmin/check-manifest rev: "0.49" hooks: diff --git a/CHANGES.md b/CHANGES.md index 02ccda0..b4585d8 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,10 @@ reverse chronological order. Releases follow [semantic versioning](https://semve and all releases are available on [Anaconda.org](https://anaconda.org/conda-forge/pytask-environment). +## 0.2.x - 2023-xx-xx + +- {pull}`17` adds ruff and refurb to pre-commits and fixes the banner. + ## 0.2.0 - 2022-16-04 - {pull}`15` aligns pytask-environment with pytask v0.2.0. diff --git a/README.md b/README.md index 30b733c..0b1066d 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![image](https://img.shields.io/conda/vn/conda-forge/pytask-environment.svg)](https://anaconda.org/conda-forge/pytask-environment) [![image](https://img.shields.io/conda/pn/conda-forge/pytask-environment.svg)](https://anaconda.org/conda-forge/pytask-environment) [![PyPI - License](https://img.shields.io/pypi/l/pytask-environment)](https://pypi.org/project/pytask-environment) -[![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) +[![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) [![image](https://codecov.io/gh/pytask-dev/pytask-environment/branch/main/graph/badge.svg)](https://codecov.io/gh/pytask-dev/pytask-environment) [![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) [![image](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) diff --git a/environment.yml b/environment.yml index e87d693..3e762a5 100644 --- a/environment.yml +++ b/environment.yml @@ -5,7 +5,7 @@ channels: - nodefaults dependencies: - - python >=3.6 + - python >=3.7 - pip - setuptools_scm - toml diff --git a/pyproject.toml b/pyproject.toml index 51b714f..6e139a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,3 +5,41 @@ build-backend = "setuptools.build_meta" [tool.setuptools_scm] write_to = "src/pytask_environment/_version.py" + + +[tool.codespell] +ignore-words-list = "falsy" + + +[tool.ruff] +select = ["ALL"] +fix = true +extend-ignore = [ + # Numpy docstyle + "D107", + "D203", + "D212", + "D213", + "D402", + "D404", + "D413", + "D415", + "D416", + "D417", + # Others. + "RET504", # unnecessary variable assignment before return. + "S101", # raise errors for asserts. + "B905", # strict parameter for zip that was implemented in py310. + "I", # ignore isort + "ANN101", # type annotating self + "ANN102", # type annotating cls + "FBT", # flake8-boolean-trap + "EM", # flake8-errmsg + "ANN401", # flake8-annotate typing.Any + "PD", # pandas-vet + "UP", # pyupgrade is too aggressive for py<3.10 +] + + +[tool.ruff.per-file-ignores] +"tests/*" = ["D", "ANN"] diff --git a/setup.cfg b/setup.cfg index b576a98..6a940a7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,10 +15,6 @@ classifiers = Operating System :: OS Independent Programming Language :: Python :: 3 Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 project_urls = Changelog = https://github.com/pytask-dev/pytask-environment/blob/main/CHANGES.md Documentation = https://github.com/pytask-dev/pytask-environment diff --git a/src/pytask_environment/config.py b/src/pytask_environment/config.py index 20f1ffe..85d517e 100644 --- a/src/pytask_environment/config.py +++ b/src/pytask_environment/config.py @@ -1,3 +1,4 @@ +"""This module contains everything related to the configuration.""" from __future__ import annotations from typing import Any @@ -61,18 +62,18 @@ def _get_first_non_none_value( the order of the inputs while also providing a default. """ - callback = (lambda x: x) if callback is None else callback # noqa: E731 + callback = (lambda x: x) if callback is None else callback processed_values = (callback(config.get(key)) for config in configs) return next((value for value in processed_values if value is not None), default) def _convert_truthy_or_falsy_to_bool(x: bool | str | None) -> bool: """Convert truthy or falsy value in .ini to Python boolean.""" - if x in [True, "True", "true", "1"]: + if x in (True, "True", "true", "1"): out = True - elif x in [False, "False", "false", "0"]: + elif x in (False, "False", "false", "0"): out = False - elif x in [None, "None", "none"]: + elif x in (None, "None", "none"): out = None else: raise ValueError( diff --git a/src/pytask_environment/database.py b/src/pytask_environment/database.py index a70b3df..8cbdd88 100644 --- a/src/pytask_environment/database.py +++ b/src/pytask_environment/database.py @@ -1,3 +1,4 @@ +"""This module contains everything related to the database.""" from __future__ import annotations from pony import orm diff --git a/src/pytask_environment/logging.py b/src/pytask_environment/logging.py index 6c2ead0..ad4cf8c 100644 --- a/src/pytask_environment/logging.py +++ b/src/pytask_environment/logging.py @@ -1,3 +1,4 @@ +"""This module contains everything related to logging.""" from __future__ import annotations import sys @@ -34,7 +35,7 @@ def pytask_log_session_header(session: Session) -> None: not session.config["check_python_version"] and not session.config["check_environment"] ): - return None + return package = retrieve_package("python") @@ -43,7 +44,7 @@ def pytask_log_session_header(session: Session) -> None: # Bail out if everything is fine. if same_version and same_path: - return None + return msg = "" if not same_version and session.config["check_python_version"]: diff --git a/src/pytask_environment/plugin.py b/src/pytask_environment/plugin.py index fe15957..c357299 100644 --- a/src/pytask_environment/plugin.py +++ b/src/pytask_environment/plugin.py @@ -1,6 +1,7 @@ """Entry-point for the plugin.""" from __future__ import annotations +from pluggy import PluginManager from pytask import hookimpl from pytask_environment import config from pytask_environment import database @@ -8,7 +9,7 @@ @hookimpl -def pytask_add_hooks(pm): +def pytask_add_hooks(pm: PluginManager) -> None: """Register some plugins.""" pm.register(logging) pm.register(config)