Skip to content

Commit

Permalink
Add "typos" tool to pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Delgan committed Oct 27, 2023
1 parent 8495742 commit 940b7cf
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions loguru/_better_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class SyntaxHighlighter:

_builtins = set(dir(builtins))
_constants = {"True", "False", "None"}
_punctation = {"(", ")", "[", "]", "{", "}", ":", ",", ";"}
_punctuation = {"(", ")", "[", "]", "{", "}", ":", ",", ";"}
_strings = {tokenize.STRING}
_fstring_middle = None

Expand Down Expand Up @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion loguru/_string_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
]
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion tests/test_add_option_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_coroutine_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_filesink_retention.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion tests/test_filesink_rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]),
Expand Down
2 changes: 1 addition & 1 deletion tests/test_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 940b7cf

Please sign in to comment.