diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3b98c575..93aed865 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,6 +5,10 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - id: check-added-large-files +- repo: https://github.com/crate-ci/typos + rev: v1.16.19 + hooks: + - id: typos - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks rev: v2.10.0 hooks: diff --git a/loguru/_better_exceptions.py b/loguru/_better_exceptions.py index fbf89e46..e751cf6e 100644 --- a/loguru/_better_exceptions.py +++ b/loguru/_better_exceptions.py @@ -45,7 +45,7 @@ class SyntaxHighlighter: _builtins = set(dir(builtins)) _constants = {"True", "False", "None"} - _punctation = {"(", ")", "[", "]", "{", "}", ":", ",", ";"} + _punctuation = {"(", ")", "[", "]", "{", "}", ":", ",", ";"} _strings = {tokenize.STRING} _fstring_middle = None @@ -79,7 +79,7 @@ def highlight(self, source): else: color = style["identifier"] elif type_ == tokenize.OP: - if string in self._punctation: + if string in self._punctuation: color = style["punctuation"] else: color = style["operator"] diff --git a/loguru/_string_parsers.py b/loguru/_string_parsers.py index da00904f..1e135ab2 100644 --- a/loguru/_string_parsers.py +++ b/loguru/_string_parsers.py @@ -67,7 +67,7 @@ def parse_duration(duration): ("d|days?", 86400), ("h|hours?", 3600), ("min(?:ute)?s?", 60), - ("s|sec(?:ond)?s?", 1), + ("s|sec(?:ond)?s?", 1), # spellchecker: disable-line ("ms|milliseconds?", 0.001), ("us|microseconds?", 0.000001), ] diff --git a/pyproject.toml b/pyproject.toml index 7ad1ebd6..94ddbb91 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,3 +22,9 @@ select = ["F", "E", "W", "I", "B", "N"] [tool.ruff.pycodestyle] max-doc-length = 100 + +[tool.typos.default] +extend-ignore-re = ["(?Rm)^.*# spellchecker: disable-line$"] + +[tool.typos.files] +extend-exclude = ["tests/exceptions/output/**"] # False positive due to ansi sequences. diff --git a/tests/test_add_option_filter.py b/tests/test_add_option_filter.py index 031ea5ac..12e5a130 100644 --- a/tests/test_add_option_filter.py +++ b/tests/test_add_option_filter.py @@ -23,7 +23,7 @@ {"tests.test_add_option_filter.": False}, ], ) -def test_filterd_in(filter, writer): +def test_filtered_in(filter, writer): logger.add(writer, filter=filter, format="{message}") logger.debug("Test Filter") assert writer.read() == "Test Filter\n" diff --git a/tests/test_coroutine_sink.py b/tests/test_coroutine_sink.py index 8573bc47..59900764 100644 --- a/tests/test_coroutine_sink.py +++ b/tests/test_coroutine_sink.py @@ -101,7 +101,7 @@ async def worker(): assert out == "A message\n" -def test_run_mutiple_different_loops(capsys): +def test_run_multiple_different_loops(capsys): async def worker(i): logger.debug("Message {}", i) await logger.complete() diff --git a/tests/test_filesink_retention.py b/tests/test_filesink_retention.py index 7689faf9..a8fab8ae 100644 --- a/tests/test_filesink_retention.py +++ b/tests/test_filesink_retention.py @@ -353,6 +353,6 @@ def test_invalid_retention(retention): "retention", ["W5", "monday at 14:00", "sunday", "nope", "5 MB", "3 hours 2 dayz", "d", "H", "__dict__"], ) -def test_unkown_retention(retention): +def test_unknown_retention(retention): with pytest.raises(ValueError): logger.add("test.log", retention=retention) diff --git a/tests/test_filesink_rotation.py b/tests/test_filesink_rotation.py index decbf959..897baaf3 100644 --- a/tests/test_filesink_rotation.py +++ b/tests/test_filesink_rotation.py @@ -122,7 +122,7 @@ def test_size_rotation(freeze_time, tmp_path, size): ("w6 at 00", [8, 24 * 7, 24 * 6, 24, 24 * 8]), (" W6 at 13 ", [0.5, 1, 24 * 6, 24 * 6, 365 * 24]), ("w2 at 11:00:00 AM", [48 + 22, 3, 24 * 6, 24, 366 * 24]), - ("MoNdAy at 11:00:30.123", [22, 24, 24, 24 * 7, 24 * 7]), + ("MonDaY at 11:00:30.123", [22, 24, 24, 24 * 7, 24 * 7]), ("sunday", [0.1, 24 * 7 - 10, 24, 24 * 6, 24 * 7]), ("SUNDAY at 11:00", [1, 24 * 7, 2, 24 * 7, 30 * 12]), ("sunDAY at 1:0:0.0 pm", [0.9, 0.2, 24 * 7 - 2, 3, 24 * 8]), diff --git a/tests/test_opt.py b/tests/test_opt.py index 83d83c08..13a40e7a 100644 --- a/tests/test_opt.py +++ b/tests/test_opt.py @@ -100,7 +100,7 @@ def test_exception_class(writer): assert lines[-1] == "ZeroDivisionError: division by zero" -def test_exception_log_funcion(writer): +def test_exception_log_function(writer): logger.add(writer, format="{level.no} {message}") try: