Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pre-commit issues #2967

Merged
merged 6 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .devcontainer/post_create.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/bin/bash

sudo apt-get update
sudo apt-get install -y libaspell-dev

Expand Down
22 changes: 9 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ repos:
hooks:
- id: no-commit-to-branch
args: [--branch, main]
- id: check-toml
- id: check-yaml
args: [--unsafe]
- id: debug-statements
Expand All @@ -48,45 +47,42 @@ repos:
- id: check-case-conflict
- id: check-toml
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.29.0
rev: v1.32.0
hooks:
- id: yamllint
args:
- --no-warnings
- -d
- '{extends: relaxed, rules: {line-length: {max: 90}}}'
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.254
rev: v0.0.280
hooks:
- id: ruff
- repo: https://github.com/PyCQA/autoflake
rev: v2.0.1
rev: v2.2.0
hooks:
- id: autoflake
- repo: https://github.com/psf/black
rev: 23.1.0
rev: 23.7.0
hooks:
- id: black
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
rev: v2.2.5
hooks:
- id: codespell
args: [--toml, pyproject-codespell.precommit-toml]
additional_dependencies:
- tomli
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.12.1
rev: v0.13
hooks:
- id: validate-pyproject
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
rev: v1.4.1
hooks:
- id: mypy
args: [--no-warn-unused-ignores, --config-file, pyproject.toml, --disable-error-code,
import]
args: ["--config-file", "pyproject.toml"]
additional_dependencies:
- chardet
- pytest
- pytest-cov
- pytest-dependency
- tomli
- types-chardet
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@ pytest:

clean:
rm -rf codespell.1

mypy:
mypy .
2 changes: 1 addition & 1 deletion codespell_lib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._codespell import _script_main, main
from ._version import __version__
from ._version import __version__ # type: ignore

__all__ = ["_script_main", "main", "__version__"]
12 changes: 6 additions & 6 deletions codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from typing import Dict, List, Match, Optional, Pattern, Sequence, Set, Tuple

# autogenerated by setuptools_scm
from ._version import __version__ as VERSION # noqa: N812
from ._version import __version__ as VERSION # type: ignore # noqa: N812

word_regex_def = "[\\w\\-'’`]+"
# While we want to treat characters like ( or " as okay for a starting break,
Expand Down Expand Up @@ -550,18 +550,18 @@ def parse_options(
toml_files.append(options.toml)
tomllib_raise_error = True
if toml_files:
try:
import tomllib # type: ignore[import]
except ModuleNotFoundError:
if sys.version_info >= (3, 11):
import tomllib
else:
try:
import tomli as tomllib
import tomli as tomllib # type: ignore[no-redef]
except ImportError as e:
if tomllib_raise_error:
raise ImportError(
f"tomllib or tomli are required to read pyproject.toml "
f"but could not be imported, got: {e}"
) from None
tomllib = None
tomllib = None # type: ignore[assignment]
if tomllib is not None:
for toml_file in toml_files:
with open(toml_file, "rb") as f:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ expand-star-imports = true
pretty = true
show_error_codes = true
strict = true
warn_unused_ignores = false

[tool.pytest.ini_options]
addopts = "--cov=codespell_lib -rs --cov-report= --tb=short --junit-xml=junit-results.xml"
Expand Down