Skip to content

Commit

Permalink
switch to ruff 0.2.2 and fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Feb 22, 2024
1 parent 02c06f6 commit 0bf3d24
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
ls -l
- name: Download ruff
run: |
wget -c https://github.com/astral-sh/ruff/releases/download/v0.1.14/ruff-0.1.14-x86_64-unknown-linux-gnu.tar.gz
wget -c https://github.com/astral-sh/ruff/releases/download/v0.2.2/ruff-0.2.2-x86_64-unknown-linux-gnu.tar.gz
tar -xzf ruff-*.tar.gz
ls -l ruff
chmod a+x ruff
Expand Down
3 changes: 2 additions & 1 deletion pyglossary/glossary.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def read(
format: str = "",
direct: bool = False,
progressbar: bool = True,
**kwargs, # noqa: ANN
**kwargs, # noqa: ANN003
) -> bool:
"""
Read from a given glossary file.
Expand All @@ -63,6 +63,7 @@ def read(
progressbar (bool): enable progressbar.
read-options can be passed as additional keyword arguments
"""
if type(filename) is not str:
raise TypeError("filename must be str")
Expand Down
2 changes: 2 additions & 0 deletions pyglossary/glossary_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ def wordTitleStr(
in definition (as title), this method will return empty string
- depending on glossary's `sourceLang` or writing system of `word`,
(or sample if given) either '<b>' or '<big>' will be used.
"""
if self._defiHasWordTitle:
return ""
Expand Down Expand Up @@ -806,6 +807,7 @@ def write(
encoding for sorting, default utf-8
You can pass write-options (of given format) as keyword arguments
"""
if type(filename) is not str:
raise TypeError("filename must be str")
Expand Down
2 changes: 2 additions & 0 deletions pyglossary/plugins/appledict/_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def title_long(s: str) -> str:
Example:
-------
title_long("str[ing]") -> "string".
"""
return s.replace("[", "").replace("]", "")

Expand All @@ -147,5 +148,6 @@ def title_short(s: str) -> str:
Example:
-------
title_short("str[ing]") -> "str".
"""
return spaces(re_title_short.sub("", s))
1 change: 1 addition & 0 deletions pyglossary/plugins/babylon_bgl/bgl_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,7 @@ def readEntryAlts(
(False, None, None) if error
(True, pos, u_alts) if succeed
u_alts is a sorted list, items are str (utf-8).
"""
Err = (False, None, None)
# use set instead of list to prevent duplicates
Expand Down
14 changes: 7 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
line-length = 88
target-version = "py310"

select = [
lint.select = [
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"COM", # flake8-commas
Expand Down Expand Up @@ -31,7 +31,7 @@ select = [
# "S", # flake8-bandit
# "ANN", # flake8-annotationsq, still gives errors for `self`
]
ignore = [
lint.ignore = [
"PGH003", # Use specific rule codes when ignoring type issues
"B019", # Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks
"D100", # Missing docstring in public module
Expand Down Expand Up @@ -68,7 +68,7 @@ ignore = [
# since which Python is comma after **kwargs allowd?

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = [
lint.fixable = [
"UP010", # Unnecessary `__future__`"
"SIM108", # Use ternary operator {contents} instead of if-else-block
"C408", # Unnecessary `dict` call (rewrite as a literal)
Expand Down Expand Up @@ -97,7 +97,7 @@ fixable = [
"UP035", # Import from `collections.abc` instead: `Generator|Iterator`
# "TCH003", Move standard library import `...` into a type-checking block
]
unfixable = []
lint.unfixable = []

# Exclude a variety of commonly ignored directories.
exclude = [
Expand Down Expand Up @@ -130,10 +130,10 @@ exclude = [
]

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
lint.dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"


[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"scripts/wiki-formats.py" = ["E501"]
"pyglossary/io_utils.py" = ["ANN"]
"pyglossary/plugin_lib/*.py" = ["ANN"]
Expand All @@ -154,7 +154,7 @@ skip-magic-trailing-comma = false
# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"

[tool.ruff.mccabe]
[tool.ruff.lint.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10

Expand Down

0 comments on commit 0bf3d24

Please sign in to comment.