Skip to content

Commit

Permalink
Update pre-commit hooks (#446)
Browse files Browse the repository at this point in the history
* Update pre-commit hooks

* Update python for linters

* Update mypy

* Disable docformatter
  • Loading branch information
hukkin authored Oct 7, 2024
1 parent 4fc013c commit 671afe3
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: '3.8'
python-version: '3.11'

- name: Installation (deps and package)
run: |
pip install . pre-commit mypy==0.910 -r tests/requirements.txt
pip install . pre-commit mypy==1.11.2 -r tests/requirements.txt
- name: run linters
run: |
Expand Down
21 changes: 13 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: f71fa2c1f9cf5cb705f73dffe4b21f7c61470ba9 # frozen: v4.4.0
rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0
hooks:
- id: check-yaml
- id: check-toml
Expand All @@ -23,22 +23,27 @@ repos:
hooks:
- id: absolufy-imports
- repo: https://github.com/PyCQA/isort
rev: dbf82f2dd09ae41d9355bcd7ab69187a19e6bf2f # frozen: 5.12.0
rev: c235f5e450b4b84e58d114ed4c589cbf454175a3 # frozen: 5.13.2
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 193ee766ca496871f93621d6b58d57a6564ff81b # frozen: 23.7.0
rev: b965c2a5026f8ba399283ba3e01898b012853c79 # frozen: 24.8.0
hooks:
- id: black
- repo: https://github.com/myint/docformatter
rev: dfefe062799848234b4cd60b04aa633c0608025e # frozen: v1.7.5
hooks:
- id: docformatter
# Disable docformatter until https://github.com/PyCQA/docformatter/pull/287 is merged
#- repo: https://github.com/PyCQA/docformatter
# rev: dfefe062799848234b4cd60b04aa633c0608025e # frozen: v1.7.5
# hooks:
# - id: docformatter
- repo: https://github.com/PyCQA/flake8
rev: 10f4af6dbcf93456ba7df762278ae61ba3120dc6 # frozen: 6.1.0
rev: e43806be3607110919eff72939fda031776e885a # frozen: 7.1.1
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear
- flake8-builtins
- flake8-comprehensions
- repo: https://github.com/pre-commit/pre-commit
rev: dbccd57db0e9cf993ea909e929eea97f6e4389ea # frozen: v4.0.0
hooks:
- id: validate_manifest
7 changes: 1 addition & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ description = run mypy
basepython = python3.8
deps =
-r tests/requirements.txt
mypy==0.910
mypy==1.11.2
commands =
mypy {posargs:src/ tests/}
Expand Down Expand Up @@ -168,8 +168,3 @@ no_implicit_optional = true
[[tool.mypy.overrides]]
module = "tests.*"
disallow_untyped_defs = false

[[tool.mypy.overrides]]
# This matches `fuzzer/fuzz.py`.
module = "fuzz"
ignore_errors = true
8 changes: 4 additions & 4 deletions src/mdformat/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ def make_arg_parser(
plugin_versions_str = get_plugin_versions_str(parser_extensions, codeformatters)
parser = argparse.ArgumentParser(
description="CommonMark compliant Markdown formatter",
epilog=f"Installed plugins: {plugin_versions_str}"
if plugin_versions_str
else None,
epilog=(
f"Installed plugins: {plugin_versions_str}" if plugin_versions_str else None
),
)
parser.add_argument("paths", nargs="*", help="files to format")
parser.add_argument(
Expand Down Expand Up @@ -254,7 +254,7 @@ def log_handler_applied(
def get_package_name(obj: object) -> str:
# Packages and modules should have `__package__`
if hasattr(obj, "__package__"):
package_name = obj.__package__ # type: ignore[attr-defined]
package_name = obj.__package__
else: # class or function
module_name = obj.__module__
package_name = module_name.split(".", maxsplit=1)[0]
Expand Down
1 change: 1 addition & 0 deletions src/mdformat/codepoints/_unicode_punctuation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Run this module to generate and print an up-to-date set of characters.
"""

UNICODE_PUNCTUATION = frozenset(
(
"!",
Expand Down
1 change: 1 addition & 0 deletions src/mdformat/codepoints/_unicode_whitespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Run this module to generate and print an up-to-date set of characters.
"""

UNICODE_WHITESPACE = frozenset(
(
"\t",
Expand Down
8 changes: 5 additions & 3 deletions tests/test_commonmark_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@
"entry",
ALL_CASES,
ids=[
c.values[0]["name"] # type: ignore[index]
if isinstance(c, ParameterSet)
else c["name"]
(
c.values[0]["name"] # type: ignore[index]
if isinstance(c, ParameterSet)
else c["name"]
)
for c in ALL_CASES
],
)
Expand Down
1 change: 1 addition & 0 deletions tests/test_for_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- `tox -e profile`
- `firefox .tox/prof/combined.svg`
"""

from pathlib import Path

from mdformat._cli import run
Expand Down

0 comments on commit 671afe3

Please sign in to comment.