From 00a0a80e720a44b4b3da7b9ba4932bdb4ce4d7d7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 30 Jan 2024 16:25:43 +0100 Subject: [PATCH] Use ruff for linting and formatting (#83) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/psf/black: 23.12.1 → 24.1.1](https://github.com/psf/black/compare/23.12.1...24.1.1) - [github.com/PyCQA/bandit: 1.7.6 → 1.7.7](https://github.com/PyCQA/bandit/compare/1.7.6...1.7.7) - [github.com/crate-ci/typos: v1.17.1 → v1.17.2](https://github.com/crate-ci/typos/compare/v1.17.1...v1.17.2) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Use ruff --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Felix Uellendall --- .pre-commit-config.yaml | 56 +++++----------------------- auto_markdown_badges/__init__.py | 1 + auto_markdown_badges/cli.py | 1 + auto_markdown_badges/custom_typer.py | 8 +++- auto_markdown_badges/utils.py | 4 +- pyproject.toml | 15 ++++++++ 6 files changed, 34 insertions(+), 51 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e62367d..3c1a9ef 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,57 +22,19 @@ repos: - types-requests - types-PyYAML - types-toml - - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.10.0 - hooks: - - id: python-check-blanket-noqa - - id: python-check-blanket-type-ignore - - id: python-check-mock-methods - - id: python-no-eval - - id: python-no-log-warn - - id: python-use-type-annotations - - repo: https://github.com/asottile/add-trailing-comma - rev: v3.1.0 - hooks: - - id: add-trailing-comma - - repo: https://github.com/asottile/pyupgrade - rev: v3.15.0 - hooks: - - id: pyupgrade - - repo: https://github.com/asottile/yesqa - rev: v1.5.0 - hooks: - - id: yesqa - repo: https://github.com/asottile/dead rev: v1.5.2 hooks: - id: dead - - repo: https://github.com/psf/black - rev: 23.12.1 - hooks: - - id: black - - repo: https://github.com/PyCQA/flake8 - rev: 7.0.0 - hooks: - - id: flake8 - args: ["--max-line-length", "88", "--extend-ignore", "E203,E501"] - - repo: https://github.com/PyCQA/bandit - rev: 1.7.6 - hooks: - - id: bandit - args: ["-c", ".bandit"] - - repo: https://github.com/PyCQA/pydocstyle - rev: 6.3.0 - hooks: - - id: pydocstyle - args: ["--convention", "pep257", "--add-ignore", "D100,D107"] - exclude: "auto_markdown_badges/cli.py|auto_markdown_badges/__main__.py|tests/" - - repo: https://github.com/pycqa/isort - rev: 5.13.2 - hooks: - - id: isort - args: ["--profile", "black"] + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.15 + hooks: + - id: ruff + args: + - --fix + - --unsafe-fixes + - id: ruff-format - repo: https://github.com/crate-ci/typos - rev: v1.17.1 + rev: v1.17.2 hooks: - id: typos diff --git a/auto_markdown_badges/__init__.py b/auto_markdown_badges/__init__.py index b2c5c16..3df67ce 100644 --- a/auto_markdown_badges/__init__.py +++ b/auto_markdown_badges/__init__.py @@ -1,4 +1,5 @@ """Top-level package for auto-markdown-badges.""" + from importlib.metadata import version from os import getcwd from os.path import dirname, join, realpath diff --git a/auto_markdown_badges/cli.py b/auto_markdown_badges/cli.py index 8e5bcb0..244c7c6 100644 --- a/auto_markdown_badges/cli.py +++ b/auto_markdown_badges/cli.py @@ -1,4 +1,5 @@ """This module provides the auto-markdown-badges CLI.""" + from enum import Enum from pathlib import Path from typing import Optional diff --git a/auto_markdown_badges/custom_typer.py b/auto_markdown_badges/custom_typer.py index 00e4aba..6409fec 100644 --- a/auto_markdown_badges/custom_typer.py +++ b/auto_markdown_badges/custom_typer.py @@ -27,19 +27,23 @@ def __init__( self, *args, cls=CustomHelpColorsGroup, - context_settings={"help_option_names": ["-h", "--help"]}, + context_settings=None, **kwargs, ) -> None: + if context_settings is None: + context_settings = {"help_option_names": ["-h", "--help"]} super().__init__(*args, cls=cls, context_settings=context_settings, **kwargs) def command( self, *args, cls=CustomHelpColorsCommand, - context_settings={"help_option_names": ["-h", "--help"]}, + context_settings=None, **kwargs, ): """Overwrite help to use colors.""" + if context_settings is None: + context_settings = {"help_option_names": ["-h", "--help"]} return super().command( *args, cls=cls, diff --git a/auto_markdown_badges/utils.py b/auto_markdown_badges/utils.py index 5275a36..da6bdfc 100644 --- a/auto_markdown_badges/utils.py +++ b/auto_markdown_badges/utils.py @@ -1,10 +1,10 @@ import re -from typing import Generator, Tuple +from collections.abc import Generator from simpleicons.all import icons -def finditer(data: str) -> Generator[Tuple[str, str], None, None]: +def finditer(data: str) -> Generator[tuple[str, str], None, None]: """ Generate replacements/badges from words. diff --git a/pyproject.toml b/pyproject.toml index b461960..79707ac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,3 +30,18 @@ build-backend = "poetry.core.masonry.api" [tool.coverage.run] omit = ["auto_markdown_badges/__main__.py"] + +[tool.ruff] +target-version = "py39" + +[tool.ruff.lint] +select = ["E4", "E7", "E9", "F", "B", "S", "UP", "PGH", "D", "I"] +ignore = ["D100", "D107"] + +[tool.ruff.per-file-ignores] +"tests/*" = ["S101", "D"] +"auto_markdown_badges/cli.py" = ["B008", "D"] +"auto_markdown_badges/__main__.py" = ["D"] + +[tool.ruff.pydocstyle] +convention = "pep257"