Skip to content

Commit

Permalink
ruff: fix more ignored errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Mar 5, 2024
1 parent 55e55b3 commit dc17df5
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 44 deletions.
50 changes: 20 additions & 30 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ lint.select = [
"EXE", # flake8-executable
"FA", # flake8-future-annotations
"ISC", # flake8-implicit-str-concat
# "G", # flake8-logging-format
# "G", # flake8-logging-format, non-sense!
"INP", # flake8-no-pep420
"PIE", # flake8-pie
"T20", # flake8-print
Expand All @@ -51,7 +51,7 @@ lint.select = [
# "TD", # flake8-todos
# "FIX", # flake8-fixme: just shows me FIXMEs and TODOs
# "ERA", # eradicate
"PD", # pandas-vet
# "PD", # pandas-vet: full of false positives
"PGH", # pygrep-hooks
# "PL", # Pylint
# "TRY", # tryceratops, they all sound BS
Expand All @@ -69,31 +69,11 @@ lint.select = [

lint.ignore = [
"PYI034", # py3.11: `__iadd__` methods in classes like `SqEntryList` usually return `self` at runtime
"INT001", # f-string is resolved before function call; consider `_("string %s") % arg`
"PERF203", # `try`-`except` within a loop incurs performance overhead
"RUF001", # String contains ambiguous `٠` (ARABIC-INDIC DIGIT ZERO). Did you mean `.` (FULL STOP)
"RUF003", # Comment contains ambiguous `۰` (EXTENDED ARABIC-INDIC DIGIT ZERO). Did you mean `.` (FULL STOP)?
"DTZ001", # The use of `datetime.datetime()` without `tzinfo` argument is not allowed
"DTZ005", # The use of `datetime.datetime.now()` without `tz` argument is not allowed
"PGH003", # Use specific rule codes when ignoring type issues
"PT027", # Use `pytest.raises` instead of unittest-style `assertRaises`, why?
"PD011", # Use `.to_numpy()` instead of `.values`, WTF?
"RUF005", # Consider `[*_list, x]` instead of concatenation
"PT009", # Use a regular `assert` instead of unittest-style `assertEqual`, why?
"PLR0911", # Too many return statements (x > 6)
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"BLE001", # Do not catch blind exception: `Exception`
"G004", # Logging statement uses f-string, WTF?
"TRY400", # Use `logging.exception` instead of `logging.error`
"TRY003", # Avoid specifying long messages outside the exception class, ???
"RUF100", # Unused `noqa` directive (non-enabled: ...)
"FURB101", # `open` and `read` should be replaced by `Path(rootConfJsonFile).read_text()`

"B019", # Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks
"COM812",
"PGH003", # Use specific rule codes when ignoring type issues
"B018", # Found useless expression. Either assign it to a variable or remove it.
"B019", # Use of `functools.lru_cache` or `functools.cache` on methods can lead to memory leaks
"B028", # No explicit `stacklevel` keyword argument found. Huh???
"BLE001", # Do not catch blind exception: `Exception`
"C408", # Unnecessary `dict` call (rewrite as a literal)
"D100", # Missing docstring in public module
"D101", # Missing docstring in public class
Expand All @@ -109,17 +89,27 @@ lint.ignore = [
"D212", # multi-line-summary-first-line, conflicts with D213:multi-line-summary-second-line
"D401", # First line of docstring should be in imperative mood
"D417", # Missing argument descriptions in the docstring
"E402", # Module level import not at top of file
"DTZ001", # The use of `datetime.datetime()` without `tzinfo` argument is not allowed
"DTZ005", # The use of `datetime.datetime.now()` without `tz` argument is not allowed
"FURB101", # `open` and `read` should be replaced by `Path(rootConfJsonFile).read_text()`
"PERF203", # `try`-`except` within a loop incurs performance overhead
"PLR0911", # Too many return statements (x > 6)
"RUF001", # String contains ambiguous `٠` (ARABIC-INDIC DIGIT ZERO). Did you mean `.` (FULL STOP)
"RUF003", # Comment contains ambiguous `۰` (EXTENDED ARABIC-INDIC DIGIT ZERO). Did you mean `.` (FULL STOP)?
"RUF005", # Consider `[*_list, x]` instead of concatenation
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"RUF100", # Unused `noqa` directive (non-enabled: ...)
"TRY003", # Avoid specifying long messages outside the exception class, ???
"TRY400", # Use `logging.exception` instead of `logging.error`

"SIM105", # Use contextlib.suppress({exception}) instead of try-except-pass
"SIM108", # Use ternary operator {contents} instead of if-else-block
"SIM117", # Use a single with statement with multiple contexts...
# ERA, PD,

"PT009", # Use a regular `assert` instead of unittest-style `assertEqual`, why?
"PT027", # Use `pytest.raises` instead of unittest-style `assertRaises`, why?
"RET502", # Do not implicitly `return None` in function able to return non-`None` value

# S: global
"E402", # Module level import not at top of file
"S101", # Use of `assert` detected

"W191", # Indentation contains tabs
]

Expand Down
10 changes: 4 additions & 6 deletions scal3/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
from scal3.time_utils import getJhmsFromEpoch

try:
__file__
__file__ # noqa: B018
except NameError:
import inspect

Expand Down Expand Up @@ -119,13 +119,11 @@ def loadConf() -> None:
###########
loadModuleJsonConf(__name__)
###########
try:
version
except NameError:
prefVersion = ""
else:
if "version" in globals():
prefVersion = version
del version
else:
prefVersion = ""
###########
with suppress(NameError):
# activeCalTypes and inactiveCalType might be
Expand Down
8 changes: 4 additions & 4 deletions scal3/format_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def tz(cell, _calType, _tm):
+ _(tm[2], fillZero=2)
+ " "
+ _("AM" if tm[0] < 12 else "PM"),
)
),
)
pyFmt += "%s"
i += 2
Expand All @@ -391,7 +391,7 @@ def tz(cell, _calType, _tm):
funcs.append(
lambda _cell, _calType, tm: (
_(tm[0], fillZero=2) + ":" + _(tm[1], fillZero=2),
)
),
)
pyFmt += "%s"
i += 2
Expand Down Expand Up @@ -470,7 +470,7 @@ def tz(cell, _calType, _tm):
+ _(tm[1], fillZero=2)
+ ":"
+ _(tm[2], fillZero=2),
)
),
)
pyFmt += "%s"
i += 2
Expand All @@ -483,7 +483,7 @@ def tz(cell, _calType, _tm):
+ _(tm[1], fillZero=2)
+ ":"
+ _(tm[2], fillZero=2),
)
),
)
pyFmt += "%s"
i += 2
Expand Down
7 changes: 4 additions & 3 deletions scal3/ui_gtk/event/group/universityTerm.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def drawCairo(self, cr):
y = (topMargin - layoutH) / 2 - 1
##
cr.move_to(x, y)
(cr, layout)
# (cr, layout)
###
for j in range(7):
layout = weekDayLayouts[j]
Expand All @@ -452,7 +452,8 @@ def drawCairo(self, cr):
y = topMargin + (h - topMargin) * (j + 0.5) / 7 - layoutH / 2
##
cr.move_to(x, y)
(cr, layout)
# (cr, layout)

for j in range(7):
wd = (j + core.firstWeekDay) % 7
for i, dayData in enumerate(self.data[wd]):
Expand Down Expand Up @@ -483,7 +484,7 @@ def drawCairo(self, cr):
y = topMargin + (h - topMargin) * (j + 0.5) / 7 - layoutH / 2
##
cr.move_to(x, y)
(cr, layout)
# (cr, layout)


class WeeklyScheduleWindow(gtk.Dialog):
Expand Down
2 changes: 1 addition & 1 deletion scal3/ui_gtk/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -1403,7 +1403,7 @@ def apply(self, _widget=None):
d.set_keep_above(True)
label = gtk.Label(
label=(
_(f"Some preferences need restarting {core.APP_DESC} to apply.")
_(f"Some preferences need restarting {core.APP_DESC} to apply.") # noqa: INT001
+ " "
+ _("Restart Now?")
),
Expand Down

0 comments on commit dc17df5

Please sign in to comment.