Skip to content

Commit

Permalink
update pyproject.toml and fix ruff refurb errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Jan 1, 2025
1 parent 7580a78 commit f5b1db2
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 44 deletions.
16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ lint.select = [
"W", # pycodestyle Warning
# "C90", # mccabe: C901: {name} is too complex ({complexity})
"I", # isort: unsorted-imports, missing-required-import
# "N", # pep8-naming
"D", # pydocstyle
"B", # flake8-bugbear
"UP", # pyupgrade
Expand All @@ -20,8 +19,8 @@ lint.select = [
# "S", # flake8-bandit
"BLE", # flake8-blind-except
# "FBT", # flake8-boolean-trap
# "B", flake8-bugbear
# "A", # flake8-builtins
"B", # flake8-bugbear
"A", # flake8-builtins
"COM", # flake8-commas
# "CPY", # flake8-copyright --preview
"C4", # flake8-comprehensions
Expand All @@ -32,7 +31,6 @@ lint.select = [
"EXE", # flake8-executable
"FA", # flake8-future-annotations
"ISC", # flake8-implicit-str-concat
# "G", # flake8-logging-format, non-sense!
"INP", # flake8-no-pep420
"PIE", # flake8-pie
# "T20", # flake8-print
Expand All @@ -49,18 +47,16 @@ lint.select = [
"INT", # flake8-gettext
"ARG", # flake8-unused-arguments
# "PTH", # flake8-use-pathlib
# "TD", # flake8-todos
# "FIX", # flake8-fixme: just shows me FIXMEs and TODOs
# "ERA", # eradicate
# "PD", # pandas-vet: full of false positives
"PGH", # pygrep-hooks
"PL", # Pylint
"TRY", # tryceratops, some are BS
# "FLY", # flynt
"FLY", # flynt
"NPY", # NumPy-specific rules
"AIR", # Airflow
"PERF", # Perflint
# "FURB", # refurb, ruff --preview
"FURB", # refurb
"LOG", # flake8-logging
"RUF", # Ruff-specific rules
]
Expand All @@ -69,6 +65,8 @@ lint.select = [
# To avoid unexpected behavior, we recommend disabling these rules, either by removing them from the `select` or `extend-select` configuration, or adding them to the `ignore` configuration.

lint.ignore = [
"FURB189", # Subclassing `list` can be error prone, use `collections.UserList` instead
"FURB103", # `open` and `write` should be replaced by `Path(...)....`
"PYI024", # Use `typing.NamedTuple` instead of `collections.namedtuple`
"PLC0206", # Extracting value from dictionary without calling `.items()`

Expand Down Expand Up @@ -203,6 +201,8 @@ lint.dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
"PYI024", # Use `typing.NamedTuple` instead of `collections.namedtuple`
]

"tools/afghanistan-events.py" = ["FLY"]

[tool.ruff.format]
quote-style = "double"
indent-style = "tab"
Expand Down
3 changes: 1 addition & 2 deletions scal3/event_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,7 @@ def do_removeUnusedObjects():
if not history:
log.error(f"No history in file: {fpath}")
continue
for _revTime, revHash in history:
hashSet.add(revHash)
hashSet.update({revHash for _revTime, revHash in history})

log.info(f"Found {len(hashSet)} used objects")
removedCount = 0
Expand Down
4 changes: 1 addition & 3 deletions scal3/graph_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ def addBoxHeightToColoredGraph(g):
colorCount = max(colors) + 1
heightList = [1 for i in range(n)]
for i, c in enumerate(colors):
adjColors = set()
for j in adjlist[i]:
adjColors.add(colors[j])
adjColors = {colors[j] for j in adjlist[i]}
for c_end in range(c + 1, colorCount + 1):
if c_end in adjColors:
heightList[i] = c_end - c
Expand Down
2 changes: 1 addition & 1 deletion scal3/os_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def makeDir(direc):
def getUsersData():
data = []
with open("/etc/passwd", encoding="utf-8") as fp:
for line in fp.readlines():
for line in fp:
parts = line.strip().split(":")
if len(parts) < 7:
continue
Expand Down
2 changes: 1 addition & 1 deletion scal3/ui_gtk/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(
self.enable = False
self.objName = name
self.desc = desc
self.moduleName = ".".join([pkg, name])
self.moduleName = f"{pkg}.{name}"
self.customizable = customizable
self.optionsWidget = None
self.items = []
Expand Down
16 changes: 2 additions & 14 deletions scal3/ui_gtk/event/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@ def getWidgetClass(obj):
if hasattr(cls, "WidgetClass"):
return cls.WidgetClass

modulePath = ".".join(
[
modPrefix,
cls.tname,
cls.name,
],
)
modulePath = f"{modPrefix}.{cls.tname}.{cls.name}"
try:
module = __import__(modulePath, fromlist=["WidgetClass"])
except Exception:
Expand Down Expand Up @@ -55,13 +49,7 @@ def setActionFuncs(obj):
cls = obj.__class__
try:
module = __import__(
".".join(
[
modPrefix,
cls.tname,
cls.name,
],
),
f"{modPrefix}.{cls.tname}.{cls.name}",
fromlist=["WidgetClass"],
)
except Exception:
Expand Down
10 changes: 2 additions & 8 deletions scal3/ui_gtk/mainwin_items/monthCal.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,7 @@ def __init__(self, win):
gtk.DrawingArea.__init__(self)
self.add_events(gdk.EventMask.ALL_EVENTS_MASK)
self.initCal()
self.pagePath = ".".join(
[
win.objName,
win.mainVBox.objName,
self.objName,
],
)
self.pagePath = f"{win.objName}.{win.mainVBox.objName}.{self.objName}"
# ----------------------
# self.kTime = 0
# ----------------------
Expand Down Expand Up @@ -404,7 +398,7 @@ def drawWithContext(self, cr: cairo.Context, cursor: bool):
iconsN = len(iconList)
scaleFact = 1 / sqrt(iconsN)
fromRight = 0
for _index, icon in enumerate(iconList):
for icon in iconList:
# if len(iconList) > 1 # FIXME
try:
pix = pixbufFromFile(icon, size=iconSizeMax)
Expand Down
7 changes: 1 addition & 6 deletions scal3/ui_gtk/starcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,7 @@ def createItems(self):
if enable:
try:
module = __import__(
".".join(
[
itemsPkg,
name,
],
),
f"{itemsPkg}.{name}",
fromlist=["CalObj"],
)
CalObj = module.CalObj
Expand Down
2 changes: 1 addition & 1 deletion scal3/ui_gtk/statusBar.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def onConfigChange(self, *a, **kw):
def onDateChange(self, *a, **kw):
CustomizableCalObj.onDateChange(self, *a, **kw)
labels = self.labelBox.get_children()
for _i, label in enumerate(labels):
for label in labels:
text = ui.cell.format(ud.dateFormatBin, label.calType)
if label.calType == calTypes.primary:
text = f"<b>{text}</b>"
Expand Down

0 comments on commit f5b1db2

Please sign in to comment.