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

Add codespell configuration, pre-commit hook + make it fix some typos #1918

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,8 @@ repos:
hooks:
- id: mypy
exclude: ^(docs/|example-plugin/)
- repo: https://github.com/codespell-project/codespell
# Configuration for codespell is in setup.cfg
rev: v2.2.6
hooks:
- id: codespell
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note -- this is just a check, not a fixer, so if false positive - just add a skip in setup.cfg; i.e. there would be no bugs introduced by codespell

2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ confidence=INFERENCE_FAILURE
# can either give multiple identifiers separated by comma (,) or put this
# option multiple times (only on the command line, not in the configuration
# file where it should appear only once).You can also use "--disable=all" to
# disable everything first and then reenable specific checks. For example, if
# disable everything first and then re-enable specific checks. For example, if
# you want to run only the similarities checker, you can use "--disable=all
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
Expand Down
2 changes: 1 addition & 1 deletion docs/source/internal/writing-documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Use the option template for new options
All of |Flake8|'s command-line options are documented in the User Guide. Each
option is documented individually using the ``.. option::`` directive provided
by Sphinx. At the top of the document, in a reStructuredText comment, is a
template that should be copied and pasted into place when documening new
template that should be copied and pasted into place when documenting new
options.

.. note::
Expand Down
2 changes: 1 addition & 1 deletion docs/source/release-notes/2.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

- Add FLAKE8_LAZY and FLAKE8_IGNORE environment variable support to git and
mercurial hooks
- Force git and mercurial hooks to repsect configuration in setup.cfg
- Force git and mercurial hooks to respect configuration in setup.cfg
- Only check staged files if that is specified
- Fix hook file permissions
- Fix the git hook on python 3
Expand Down
6 changes: 6 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,9 @@ warn_unused_ignores = true

[mypy-tests.*]
disallow_untyped_defs = false

[codespell]
skip = .git
check-hidden = true
ignore-regex = \bNed Batchelder\b
ignore-words-list = dne
2 changes: 1 addition & 1 deletion src/flake8/main/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def run_checks(self) -> None:
"""Run the actual checks with the FileChecker Manager.

This method encapsulates the logic to make a
:class:`~flake8.checker.Manger` instance run the checks it is
:class:`~flake8.checker.Manager` instance run the checks it is
managing.
"""
assert self.file_checker_manager is not None
Expand Down
2 changes: 1 addition & 1 deletion src/flake8/options/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _find_config_file(path: str) -> str | None:
try:
cfg.read(cfg_path, encoding="UTF-8")
except (UnicodeDecodeError, configparser.ParsingError) as e:
LOG.warning("ignoring unparseable config %s: %s", cfg_path, e)
LOG.warning("ignoring unparsable config %s: %s", cfg_path, e)
else:
# only consider it a config if it contains flake8 sections
if "flake8" in cfg or "flake8:local-plugins" in cfg:
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_options_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_config_file_with_parse_error_is_not_considered(tmp_path, caplog):
assert len(caplog.record_tuples) == 1
((mod, level, msg),) = caplog.record_tuples
assert (mod, level) == ("flake8.options.config", 30)
assert msg.startswith("ignoring unparseable config ")
assert msg.startswith("ignoring unparsable config ")


def test_config_file_with_encoding_error_is_not_considered(tmp_path, caplog):
Expand All @@ -43,7 +43,7 @@ def test_config_file_with_encoding_error_is_not_considered(tmp_path, caplog):
assert len(caplog.record_tuples) == 1
((mod, level, msg),) = caplog.record_tuples
assert (mod, level) == ("flake8.options.config", 30)
assert msg.startswith("ignoring unparseable config ")
assert msg.startswith("ignoring unparsable config ")


@pytest.mark.parametrize("cfg_name", ("setup.cfg", "tox.ini", ".flake8"))
Expand Down