Skip to content

Commit

Permalink
Use ruff for linting and formatting (#83)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/psf/black: 23.12.1 → 24.1.1](psf/black@23.12.1...24.1.1)
- [github.com/PyCQA/bandit: 1.7.6 → 1.7.7](PyCQA/bandit@1.7.6...1.7.7)
- [github.com/crate-ci/typos: v1.17.1 → v1.17.2](crate-ci/typos@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 <[email protected]>
  • Loading branch information
pre-commit-ci[bot] and feluelle authored Jan 30, 2024
1 parent 2181e54 commit 00a0a80
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 51 deletions.
56 changes: 9 additions & 47 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions auto_markdown_badges/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions auto_markdown_badges/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module provides the auto-markdown-badges CLI."""

from enum import Enum
from pathlib import Path
from typing import Optional
Expand Down
8 changes: 6 additions & 2 deletions auto_markdown_badges/custom_typer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions auto_markdown_badges/utils.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
15 changes: 15 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 00a0a80

Please sign in to comment.