diff --git a/.devcontainer/post_create.sh b/.devcontainer/post_create.sh index b427fa873d..14607e1673 100644 --- a/.devcontainer/post_create.sh +++ b/.devcontainer/post_create.sh @@ -1,5 +1,3 @@ -#!/bin/bash - sudo apt-get update sudo apt-get install -y libaspell-dev diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a84ea01b01..491371d902 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -48,7 +47,7 @@ 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: @@ -56,37 +55,34 @@ repos: - -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 diff --git a/Makefile b/Makefile index a528e048a3..0c239e5938 100644 --- a/Makefile +++ b/Makefile @@ -59,3 +59,6 @@ pytest: clean: rm -rf codespell.1 + +mypy: + mypy . diff --git a/codespell_lib/__init__.py b/codespell_lib/__init__.py index cd77a5534c..4484dbd4fe 100644 --- a/codespell_lib/__init__.py +++ b/codespell_lib/__init__.py @@ -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__"] diff --git a/codespell_lib/_codespell.py b/codespell_lib/_codespell.py index bdfd0a6f24..19999cdbd6 100644 --- a/codespell_lib/_codespell.py +++ b/codespell_lib/_codespell.py @@ -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, @@ -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: diff --git a/pyproject.toml b/pyproject.toml index c3348f18c2..20161023d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"