From 321436dc07927759fe120784e4b7faba61509c40 Mon Sep 17 00:00:00 2001 From: Saeed Rasooli Date: Mon, 23 Dec 2024 02:46:51 +0330 Subject: [PATCH] fix ruff errors --- mytz/tree/tree_unix.py | 12 +-- .../pray_times_files/pray_times_backend.py | 2 +- scal3/account/starcal.py | 19 +++-- scal3/cal_types/gregorian_proleptic.py | 2 +- scal3/cal_types/hijri.py | 4 +- scal3/cal_types/julian.py | 2 +- scal3/date_utils.py | 2 +- scal3/event_lib.py | 76 +++++++++---------- scal3/interval_utils.py | 6 +- scal3/moon.py | 2 +- scal3/os_utils.py | 2 +- scal3/plugin_man.py | 51 +++++++------ scal3/s_object.py | 52 ++++++------- scal3/ui_gtk/event/editor.py | 1 - scal3/ui_gtk/event/manager.py | 14 ++-- scal3/ui_gtk/mywidgets/clock.py | 4 +- scal3/ui_gtk/mywidgets/text_widgets.py | 6 +- scal3/ui_gtk/pluginsText.py | 6 +- scal3/ui_gtk/pref_utils.py | 6 +- scal3/ui_gtk/pref_utils_extra.py | 24 +++--- scal3/utils.py | 4 +- scal3/vcs_modules/git.py | 2 +- 22 files changed, 153 insertions(+), 146 deletions(-) diff --git a/mytz/tree/tree_unix.py b/mytz/tree/tree_unix.py index 8f5b2292f..b26fb6ae6 100644 --- a/mytz/tree/tree_unix.py +++ b/mytz/tree/tree_unix.py @@ -8,23 +8,23 @@ def findZoneInfoDir(): - for _dir in ( + for dir_ in ( "/usr/share/zoneinfo", "/usr/lib/zoneinfo", "/usr/share/lib/zoneinfo", "/etc/zoneinfo", ): - if os.path.isdir(_dir): - return _dir + if os.path.isdir(dir_): + return dir_ try: import pytz except ImportError: pass else: - _dir = os.path.join(os.path.dirname(pytz.__file__), "zoneinfo") - if os.path.isdir(_dir): - return _dir + dir_ = os.path.join(os.path.dirname(pytz.__file__), "zoneinfo") + if os.path.isdir(dir_): + return dir_ raise OSError("zoneinfo directory not found") diff --git a/plugins/pray_times_files/pray_times_backend.py b/plugins/pray_times_files/pray_times_backend.py index 4339eb653..1efba12c8 100644 --- a/plugins/pray_times_files/pray_times_backend.py +++ b/plugins/pray_times_files/pray_times_backend.py @@ -236,7 +236,7 @@ def __init__( timeFormat="24h", ): """ - timeFormat possible values: + TimeFormat possible values: "24h" "12h" "12hNS": 12-hour format with no suffix diff --git a/scal3/account/starcal.py b/scal3/account/starcal.py index 91671921f..cc053cc9c 100644 --- a/scal3/account/starcal.py +++ b/scal3/account/starcal.py @@ -22,6 +22,7 @@ from contextlib import suppress from datetime import datetime +from typing import TYPE_CHECKING from scal3 import event_lib from scal3.cal_types import ( @@ -33,6 +34,10 @@ jsonTimeFromEpoch, ) +if TYPE_CHECKING: + from scal3.event_lib import Event, EventGroup + + # def encodeDateTimeRuleValue( # return { # "date": dateEncode(self.date), @@ -95,13 +100,15 @@ def _emptyDecoder(_ev): } -def decodeRemoteEvent(remoteEventFull, accountId, _group): +def decodeRemoteEvent( + remoteEventFull: dict, + accountId: int, + _group: EventGroup, +) -> tuple[Event | None, str | None]: """ - remoteEventFull is dict. - - return (event, error) + Return (event, error) where event is instance of event_lib.Event, or None - and error is string or None + and error is string or None. """ try: eventType = remoteEventFull["eventType"] @@ -172,7 +179,7 @@ def callBase(self, method, path, **kwargs): def call(self, method, path, **kwargs): """ - return (data, None) if successful + Return (data, None) if successful return (data, error) if failed where error is string and data is a dict. """ diff --git a/scal3/cal_types/gregorian_proleptic.py b/scal3/cal_types/gregorian_proleptic.py index 75cd972f7..66b38ac53 100644 --- a/scal3/cal_types/gregorian_proleptic.py +++ b/scal3/cal_types/gregorian_proleptic.py @@ -68,7 +68,7 @@ def getMonthNameAb(tr, m, y=None): # noqa: ARG001 def ifloor(x): - return int(floor(x)) + return floor(x) epoch = 1721426 diff --git a/scal3/cal_types/hijri.py b/scal3/cal_types/hijri.py index 604fc3cef..006e2a31d 100644 --- a/scal3/cal_types/hijri.py +++ b/scal3/cal_types/hijri.py @@ -122,11 +122,11 @@ def getMonthNameAb(tr, m, y=None): # noqa: ARG001 def ifloor(x: float) -> int: - return int(floor(x)) + return floor(x) def iceil(x: float) -> int: - return int(ceil(x)) + return ceil(x) def save(): diff --git a/scal3/cal_types/julian.py b/scal3/cal_types/julian.py index d099978e0..746ac7a3a 100644 --- a/scal3/cal_types/julian.py +++ b/scal3/cal_types/julian.py @@ -26,7 +26,7 @@ def ifloor(x): - return int(floor(x)) + return floor(x) monthName = ( diff --git a/scal3/date_utils.py b/scal3/date_utils.py index 4a0c41732..44a1e1adb 100644 --- a/scal3/date_utils.py +++ b/scal3/date_utils.py @@ -113,7 +113,7 @@ def getFloatYearFromJd(jd: int, calType: int) -> float: def getJdFromFloatYear(fyear: float, calType: int) -> int: if calType not in calTypes: raise RuntimeError(f"cal type '{calType}' not found") - year = int(math.floor(fyear)) + year = math.floor(fyear) yearStartJd = to_jd(year, 1, 1, calType) nextYearStartJd = to_jd(year + 1, 1, 1, calType) dayOfYear = int((fyear - year) * (nextYearStartJd - yearStartJd)) diff --git a/scal3/event_lib.py b/scal3/event_lib.py index 44004b96e..53c3e11cb 100644 --- a/scal3/event_lib.py +++ b/scal3/event_lib.py @@ -264,11 +264,11 @@ def scanDir(self, dpath: str) -> int: if ext != ".json": continue try: - _id = int(idStr) + id_ = int(idStr) except ValueError: log.error(f"invalid file name: {dpath}") continue - lastId = max(_id, lastId) + lastId = max(id_, lastId) return lastId def scan(self) -> None: @@ -2271,7 +2271,7 @@ def getNotifyBeforeMin(self): def setDefaults(self, group=None): """ - sets default values that depends on event type and group type + Sets default values that depends on event type and group type as well as common parameters, like those are set in __init__ should call this method from parent event class. """ @@ -2355,13 +2355,13 @@ def getTextParts(self, showDesc=True): def getText(self, showDesc=True): return "".join(self.getTextParts(showDesc)) - def setId(self, _id=None): - if _id is None or _id < 0: - _id = lastIds.event + 1 # FIXME - lastIds.event = _id - elif _id > lastIds.event: - lastIds.event = _id - self.id = _id + def setId(self, id_=None): + if id_ is None or id_ < 0: + id_ = lastIds.event + 1 # FIXME + lastIds.event = id_ + elif id_ > lastIds.event: + lastIds.event = id_ + self.id = id_ self.file = self.getFile(self.id) # self.filesDir = join(self.dir, "files") self.loadFiles() @@ -3935,7 +3935,7 @@ def moveDown(self, index): def remove(self, event: Event): # call when moving to trash """ - excludes event from this container (group or trash), + Excludes event from this container (group or trash), not delete event data completely and returns the index of (previously contained) event. """ @@ -3967,7 +3967,7 @@ def setData(self, data) -> None: def getEventNoCache(self, eid: int) -> Event: """ - no caching. and no checking if group contains eid + No caching. and no checking if group contains eid used only for sorting events. """ event = EventContainer._getEvent(self, eid) @@ -4313,20 +4313,20 @@ def getLastSync(self) -> int | None: def setDefaults(self) -> None: """ - sets default values that depends on group type + Sets default values that depends on group type not common parameters, like those are set in __init__. """ def __bool__(self) -> bool: return self.enable # FIXME - def setId(self, _id: int | None = None) -> None: - if _id is None or _id < 0: - _id = lastIds.group + 1 # FIXME - lastIds.group = _id - elif _id > lastIds.group: - lastIds.group = _id - self.id = _id + def setId(self, id_: int | None = None) -> None: + if id_ is None or id_ < 0: + id_ = lastIds.group + 1 # FIXME + lastIds.group = id_ + elif id_ > lastIds.group: + lastIds.group = id_ + self.id = id_ self.file = self.getFile(self.id) def setTitle(self, title: str) -> None: @@ -5010,7 +5010,7 @@ def getWeeklyScheduleData( currentWeekOnly: bool = False, ) -> list[list[list[dict[str, Any]]]]: """ - returns `data` as a nested list that: + Returns `data` as a nested list that: data[weekDay][classIndex] = WeeklyScheduleItem(name, weekNumMode) where weekDay: int, in range(7) @@ -5828,18 +5828,18 @@ def setData(self, data: list[int]) -> None: for sid in data: if not isinstance(sid, int) or sid == 0: raise RuntimeError(f"unexpected {sid=}, {self=}") - _id = sid - _id = abs(sid) + id_ = sid + id_ = abs(sid) try: cls = getattr(classes, self.childName).main - obj = cls.load(self.fs, _id) + obj = cls.load(self.fs, id_) except Exception: log.error(f"error loading {self.childName}") log.exception("") continue obj.parent = self obj.enable = sid > 0 - self.idList.append(_id) + self.idList.append(id_) self.byId[obj.id] = obj def getData(self) -> list[int]: @@ -6139,22 +6139,22 @@ def loadData(self, _id: int) -> dict[str, Any]: # FIXME: types def getLoadedObj(self, obj: DummyAccount) -> Account: - _id = obj.id - data = self.loadData(_id) + id_ = obj.id + data = self.loadData(id_) name = data["type"] cls = self.loadClass(name) if cls is None: return - obj = cls(_id) + obj = cls(id_) obj.fs = self.fs - data = self.loadData(_id) + data = self.loadData(id_) obj.setData(data) return obj def replaceDummyObj(self, obj: DummyAccount) -> Account: - _id = obj.id + id_ = obj.id obj = self.getLoadedObj(obj) - self.byId[_id] = obj + self.byId[id_] = obj return obj @@ -6298,13 +6298,13 @@ def save(self): self.setId() BsonHistEventObj.save(self) - def setId(self, _id=None): - if _id is None or _id < 0: - _id = lastIds.account + 1 # FIXME - lastIds.account = _id - elif _id > lastIds.account: - lastIds.account = _id - self.id = _id + def setId(self, id_=None): + if id_ is None or id_ < 0: + id_ = lastIds.account + 1 # FIXME + lastIds.account = id_ + elif id_ > lastIds.account: + lastIds.account = id_ + self.id = id_ self.file = self.getFile(self.id) def stop(self): diff --git a/scal3/interval_utils.py b/scal3/interval_utils.py index 0e4e410de..33d5cd7ec 100644 --- a/scal3/interval_utils.py +++ b/scal3/interval_utils.py @@ -37,7 +37,7 @@ def simplifyNumList( minCount: int = 3, ) -> list[int | tuple[int, int]]: """ - nums must be sorted + Nums must be sorted minCount >= 2. """ ranges = [] @@ -63,7 +63,7 @@ def getIntervalPoints( lst_index: int = 0, ) -> list[tuple[int, int, int]]: """ - lst is a list of (start, end, closedEnd) or (start, end) tuples + Lst is a list of (start, end, closedEnd) or (start, end) tuples start (int) end (int) closedEnd (bool). @@ -136,7 +136,7 @@ def normalizeIntervalList(lst): def humanizeIntervalList(lst): """ - replace Closed End intervals with 2 new intervals + Replace Closed End intervals with 2 new intervals in math terms: [a, b] ==> [a, b) + [b, b]. lst is a list of (start, end, closedEnd) tuples diff --git a/scal3/moon.py b/scal3/moon.py index 837495a5b..c93e9c1f2 100644 --- a/scal3/moon.py +++ b/scal3/moon.py @@ -1,6 +1,6 @@ def getMoonPhase(jd, southernHemisphere=False): """ - returns a float number that: 0 <= phase < 2 + Returns a float number that: 0 <= phase < 2 0.0 = no moon 1.0 = full moon. """ diff --git a/scal3/os_utils.py b/scal3/os_utils.py index e1ad21790..6abeb7390 100644 --- a/scal3/os_utils.py +++ b/scal3/os_utils.py @@ -90,7 +90,7 @@ def getUserDisplayName(): def kill(pid, signal=0): """ - sends a signal to a process + Sends a signal to a process returns True if the pid is dead with no signal argument, sends no signal. """ diff --git a/scal3/plugin_man.py b/scal3/plugin_man.py index 16d26492b..62d105cb0 100644 --- a/scal3/plugin_man.py +++ b/scal3/plugin_man.py @@ -236,11 +236,11 @@ def __init__(self, _file, title): # TODO: switch to fs -def loadExternalPlugin(_file, **data): - _file = getPlugPath(_file) - fname = split(_file)[-1] - if not isfile(_file): - log.error(f'plugin file "{_file}" not found! maybe removed?') +def loadExternalPlugin(file, **data): + file = getPlugPath(file) + fname = split(file)[-1] + if not isfile(file): + log.error(f'plugin file "{file}" not found! maybe removed?') # try: # plugIndex.remove( return None # FIXME @@ -258,13 +258,13 @@ def loadExternalPlugin(_file, **data): # --- if not data.get("enable"): return DummyExternalPlugin( - _file, + file, pluginsTitleByName.get(name, name), ) # --- mainFile = data.get("mainFile") if not mainFile: - log.error(f'invalid external plugin "{_file}"') + log.error(f'invalid external plugin "{file}"') return None # --- mainFile = getPlugPath(mainFile) @@ -278,19 +278,19 @@ def loadExternalPlugin(_file, **data): with open(mainFile, encoding="utf-8") as fp: exec(fp.read(), pyEnv) except Exception: - log.error(f'error while loading external plugin "{_file}"') + log.error(f'error while loading external plugin "{file}"') log.exception("") return # --- cls = pyEnv.get("TextPlugin") if cls is None: - log.error(f'invalid external plugin "{_file}", no TextPlugin class') + log.error(f'invalid external plugin "{file}", no TextPlugin class') return None # --- try: - plugin = cls(_file) + plugin = cls(file) except Exception: - log.error(f'error while loading external plugin "{_file}"') + log.error(f'error while loading external plugin "{file}"') log.exception("") return None @@ -737,19 +737,20 @@ def open_about(self): # class RandomTextPlugin(BaseJsonPlugin): +# must not rename _file argument def loadPlugin(_file=None, **kwargs): if not _file: - log.error("plugin file is empty!") + log.error(f"plugin file is empty! {kwargs=}") return - _file = getPlugPath(_file) - if not isfile(_file): - log.error(f'error while loading plugin "{_file}": no such file!\n') + file = getPlugPath(_file) + if not isfile(file): + log.error(f'error while loading plugin "{file}": no such file!\n') return - ext = splitext(_file)[1].lower() + ext = splitext(file)[1].lower() # ---- # FIXME: should ics plugins require a json file too? if ext == ".ics": - return IcsTextPlugin(_file, **kwargs) + return IcsTextPlugin(file, **kwargs) # ---- if ext == ".md": return @@ -760,17 +761,17 @@ def loadPlugin(_file=None, **kwargs): ) return try: - with open(_file, encoding="utf-8") as fp: # noqa: FURB101 + with open(file, encoding="utf-8") as fp: # noqa: FURB101 text = fp.read() except Exception as e: log.error( - f'error while reading plugin file "{_file}": {e}', + f'error while reading plugin file "{file}": {e}', ) return try: data = jsonToData(text) except Exception: - log.error(f'invalid json file "{_file}"') + log.error(f'invalid json file "{file}"') log.exception("") return # ---- @@ -778,26 +779,26 @@ def loadPlugin(_file=None, **kwargs): # ---- name = data.get("type") if not name: - log.error(f'invalid plugin "{_file}", no "type" key') + log.error(f'invalid plugin "{file}", no "type" key') return # ---- if name == "external": - return loadExternalPlugin(_file, **data) + return loadExternalPlugin(file, **data) # ---- try: cls = pluginClassByName[name] except KeyError: - log.error(f'invald plugin type "{name}" in file "{_file}"') + log.error(f'invald plugin type "{name}" in file "{file}"') return # ---- for param in cls.essentialParams: if not data.get(param): log.error( - f'invalid plugin "{_file}": parameter "{param}" is missing', + f'invalid plugin "{file}": parameter "{param}" is missing', ) return # ---- - plug = cls(_file) + plug = cls(file) plug.setData(data) # ---- return plug diff --git a/scal3/s_object.py b/scal3/s_object.py index d1560bb1c..6c9c99e57 100644 --- a/scal3/s_object.py +++ b/scal3/s_object.py @@ -149,15 +149,15 @@ def getIdPath(self): f"{self.__class__.__name__}.getIdPath: no parent attribute", ) from None try: - _id = self.id + id_ = self.id except AttributeError: raise NotImplementedError( f"{self.__class__.__name__}.getIdPath: no id attribute", ) from None # ------ path = [] - if _id is not None: - path.append(_id) + if id_ is not None: + path.append(id_) if parent is None: return path return parent.getIdPath() + path @@ -218,11 +218,11 @@ def load(cls, fs: FileSystem, *args): # data is the result of json.loads, # so probably can be only dict or list (or str) - _type = data.get("type") if isinstance(data, dict) else None - if _type is None: + type_ = data.get("type") if isinstance(data, dict) else None + if type_ is None: subCls = cls else: - subCls = cls.getSubclass(_type) + subCls = cls.getSubclass(type_) obj = subCls(*args) obj.fs = fs obj.setData(data) @@ -283,28 +283,28 @@ def iterObjectFiles(fs: FileSystem): if not fs.isfile(fpath): log.error(f"Object file does not exist or not a file: {fpath}") continue - _hash = dname + fname - if len(_hash) != 40: + hash_ = dname + fname + if len(hash_) != 40: log.debug(f"Skipping non-object file {fpath}") continue try: - int(_hash, 16) + int(hash_, 16) except ValueError: log.debug(f"Skipping non-object file {fpath} (not hexadecimal)") continue - yield _hash, fpath + yield hash_, fpath def saveBsonObject(data: dict | list, fs: FileSystem): data = getSortedDict(data) bsonBytes = bytes(bson.dumps(data)) - _hash = sha1(bsonBytes).hexdigest() - dpath, fpath = getObjectPath(_hash) + hash_ = sha1(bsonBytes).hexdigest() + dpath, fpath = getObjectPath(hash_) if not fs.isfile(fpath): fs.makeDir(dpath) with fs.open(fpath, "wb") as fp: fp.write(bsonBytes) - return _hash + return hash_ def loadBsonObject(_hash, fs: FileSystem): @@ -357,33 +357,33 @@ def getFile(cls, _id=None): @classmethod def load(cls, fs: FileSystem, *args): - _file = cls.getFile(*args) + file = cls.getFile(*args) data = {} lastEpoch, lastHash = None, None try: - with fs.open(_file) as fp: + with fs.open(file) as fp: jsonStr = fp.read() data = jsonToData(jsonStr) except FileNotFoundError: if not cls.skipLoadNoFile: - raise FileNotFoundError(f"{_file} : file not found") from None + raise FileNotFoundError(f"{file} : file not found") from None except Exception: if not cls.skipLoadExceptions: - log.error(f'error while opening json file "{_file}"') + log.error(f'error while opening json file "{file}"') raise else: - lastEpoch, lastHash = updateBasicDataFromBson(data, _file, cls.name, fs) + lastEpoch, lastHash = updateBasicDataFromBson(data, file, cls.name, fs) if lastEpoch is None: lastEpoch = now() # FIXME # data is the result of json.loads, # so probably can be only dict or list (or str) - _type = data.get("type") if isinstance(data, dict) else None - if _type is None: + type_ = data.get("type") if isinstance(data, dict) else None + if type_ is None: subCls = cls else: - subCls = cls.getSubclass(_type) + subCls = cls.getSubclass(type_) obj = subCls(*args) obj.fs = fs obj.setData(data) @@ -433,7 +433,7 @@ def save(self, *histArgs): basicData[param] = data.pop(param) if "modified" in data: del data["modified"] - _hash = saveBsonObject(data, self.fs) + hash_ = saveBsonObject(data, self.fs) # --- history = self.loadHistory() # --- @@ -441,9 +441,9 @@ def save(self, *histArgs): lastHash = history[0][1] except IndexError: lastHash = None - if _hash != lastHash: # or lastHistArgs != histArgs: # FIXME + if hash_ != lastHash: # or lastHistArgs != histArgs: # FIXME tm = now() - history.insert(0, [tm, _hash] + list(histArgs)) + history.insert(0, [tm, hash_] + list(histArgs)) self.modified = tm basicData["history"] = history self.saveBasicData(basicData) @@ -454,11 +454,11 @@ def getRevision(self, revHash, *args): data = self.loadBasicData() data.update(loadBsonObject(revHash, self.fs)) try: - _type = data["type"] + type_ = data["type"] except (KeyError, TypeError): subCls = cls else: - subCls = cls.getSubclass(_type) + subCls = cls.getSubclass(type_) obj = subCls(*args) obj.setData(data) obj.fs = self.fs diff --git a/scal3/ui_gtk/event/editor.py b/scal3/ui_gtk/event/editor.py index aac53bc74..4283a7bda 100644 --- a/scal3/ui_gtk/event/editor.py +++ b/scal3/ui_gtk/event/editor.py @@ -1,4 +1,3 @@ - from scal3 import event_lib, locale_man, ui from scal3.locale_man import tr as _ from scal3.ui_gtk import HBox, gtk, pack diff --git a/scal3/ui_gtk/event/manager.py b/scal3/ui_gtk/event/manager.py index 8354bc624..97f2acc7d 100644 --- a/scal3/ui_gtk/event/manager.py +++ b/scal3/ui_gtk/event/manager.py @@ -854,13 +854,13 @@ def multiSelectPaste(self, _obj=None): # so that events are inserted in the same order as they are selected for srcIter in iterList: - _iter = self._pasteEventToPath(srcIter, move, targetPath) + iter_ = self._pasteEventToPath(srcIter, move, targetPath) if newEventIter is None: - newEventIter = _iter + newEventIter = iter_ if not move: - for _iter in iterList: - model.set_value(_iter, 0, False) + for iter_ in iterList: + model.set_value(iter_, 0, False) if move: msg = _("{count} events successfully moved") @@ -1697,10 +1697,10 @@ def onMenuBarOrphanClick(self, _menuItem: gtk.MenuItem) -> None: self.waitingDo(self._do_checkForOrphans) def getSelectedPath(self) -> list[int] | None: - _iter = self.treev.get_selection().get_selected()[1] - if _iter is None: + iter_ = self.treev.get_selection().get_selected()[1] + if iter_ is None: return - return self.treeModel.get_path(_iter).get_indices() + return self.treeModel.get_path(iter_).get_indices() def mbarEditMenuPopup(self, _menuItem: gtk.MenuItem) -> None: path = self.getSelectedPath() diff --git a/scal3/ui_gtk/mywidgets/clock.py b/scal3/ui_gtk/mywidgets/clock.py index 53b934a39..8b6100438 100644 --- a/scal3/ui_gtk/mywidgets/clock.py +++ b/scal3/ui_gtk/mywidgets/clock.py @@ -70,7 +70,7 @@ def stop(self): class FClockLabel(gtk.Label): def __init__(self, clockFormat="%T", local=True, selectable=False): """ - clockFormat is a string that used in strftime(), it can contains markup + ClockFormat is a string that used in strftime(), it can contains markup that apears in GtkLabel for example format can be "%T" local is bool. if True, use Local time. and if False, use GMT time. selectable is bool that passes to GtkLabel. @@ -104,7 +104,7 @@ def stop(self): class FClockWidget(gtk.DrawingArea): # Time is in Local def __init__(self, clockFormat="%T", _selectable=False): """ - clockFormat is a string that used in strftime(), it can contains markup + ClockFormat is a string that used in strftime(), it can contains markup that apears in GtkLabel for example format can be "%T" local is bool. if True, use Local time. and if False, use GMT time. selectable is bool that passes to GtkLabel. diff --git a/scal3/ui_gtk/mywidgets/text_widgets.py b/scal3/ui_gtk/mywidgets/text_widgets.py index 19cccd18b..011c11ef9 100644 --- a/scal3/ui_gtk/mywidgets/text_widgets.py +++ b/scal3/ui_gtk/mywidgets/text_widgets.py @@ -105,7 +105,7 @@ def onButtonPress(self, _widget, gevent): if gevent.button != 3: return False # ---- - _iter = None + iter_ = None buf_x, buf_y = self.window_to_buffer_coords( gtk.TextWindowType.TEXT, gevent.x, @@ -113,10 +113,10 @@ def onButtonPress(self, _widget, gevent): ) if buf_x is not None and buf_y is not None: # overText, _iter, trailing = ... - _iter = self.get_iter_at_position(buf_x, buf_y)[1] + iter_ = self.get_iter_at_position(buf_x, buf_y)[1] # ---- text = self.get_text() - pos = _iter.get_offset() + pos = iter_.get_offset() word = findWordByPos(text, pos)[0] # ---- menu = Menu() diff --git a/scal3/ui_gtk/pluginsText.py b/scal3/ui_gtk/pluginsText.py index 094d80016..f49e01332 100644 --- a/scal3/ui_gtk/pluginsText.py +++ b/scal3/ui_gtk/pluginsText.py @@ -171,7 +171,7 @@ def onButtonPress(self, _widget, gevent): if gevent.button != 3: return False # ---- - _iter = None + iter_ = None buf_x, buf_y = self.window_to_buffer_coords( gtk.TextWindowType.TEXT, gevent.x, @@ -179,10 +179,10 @@ def onButtonPress(self, _widget, gevent): ) if buf_x is not None and buf_y is not None: # overText, _iter, trailing = ... - _iter = self.get_iter_at_position(buf_x, buf_y)[1] + iter_ = self.get_iter_at_position(buf_x, buf_y)[1] # ---- text = self.get_text() - pos = _iter.get_offset() + pos = iter_.get_offset() word = findWordByPos(text, pos)[0] # ---- menu = Menu() diff --git a/scal3/ui_gtk/pref_utils.py b/scal3/ui_gtk/pref_utils.py index c3dfd271a..734f328a3 100644 --- a/scal3/ui_gtk/pref_utils.py +++ b/scal3/ui_gtk/pref_utils.py @@ -774,12 +774,12 @@ def __init__( attrName: str, _max: float, ): - _min = 0 + min_ = 0 self.obj = obj self.attrName = attrName # --- - self.widthItem = IntSpinButton(_min, _max) - self.heightItem = IntSpinButton(_min, _max) + self.widthItem = IntSpinButton(min_, _max) + self.heightItem = IntSpinButton(min_, _max) # --- hbox = self._widget = HBox() pack(hbox, gtk.Label(label=_("Width") + ":")) diff --git a/scal3/ui_gtk/pref_utils_extra.py b/scal3/ui_gtk/pref_utils_extra.py index 8fc5e6394..41e0608ce 100644 --- a/scal3/ui_gtk/pref_utils_extra.py +++ b/scal3/ui_gtk/pref_utils_extra.py @@ -587,14 +587,14 @@ def inactiveTreevFocus( def onLeftRightClick(self, _obj: gtk.Button | None = None) -> None: action = self.toolbar.getLeftRightAction() if action == "activate": - model, _iter = self.inactiveTreev.get_selection() - if _iter: - self.activateIndex(model.get_path(_iter).get_indices()[0]) + model, iter_ = self.inactiveTreev.get_selection() + if iter_: + self.activateIndex(model.get_path(iter_).get_indices()[0]) elif action == "inactivate": if len(self.activeTrees) > 1: - model, _iter = self.activeTrees.get_selection() - if _iter: - self.inactivateIndex(model.get_path(_iter).get_indices()[0]) + model, iter_ = self.activeTrees.get_selection() + if iter_: + self.inactivateIndex(model.get_path(iter_).get_indices()[0]) def getCurrentTreeview(self) -> gtk.TreeView | None: action = self.toolbar.getLeftRightAction() @@ -609,10 +609,10 @@ def onUpClick(self, _obj: gtk.Button | None = None) -> None: if not treev: return selection = treev.get_selection() - model, _iter = selection.get_selected() - if not _iter: + model, iter_ = selection.get_selected() + if not iter_: return - i = model.get_path(_iter).get_indices()[0] + i = model.get_path(iter_).get_indices()[0] if i <= 0: return model.swap( @@ -626,10 +626,10 @@ def onDownClick(self, _obj: gtk.Button | None = None) -> None: if not treev: return selection = treev.get_selection() - model, _iter = selection.get_selected() - if not _iter: + model, iter_ = selection.get_selected() + if not iter_: return - i = model.get_path(_iter).get_indices()[0] + i = model.get_path(iter_).get_indices()[0] if i >= len(model) - 1: return model.swap( diff --git a/scal3/utils.py b/scal3/utils.py index c6d6a608c..0de1fd55e 100644 --- a/scal3/utils.py +++ b/scal3/utils.py @@ -30,11 +30,11 @@ def ifloor(x: float) -> int: - return int(floor(x)) + return floor(x) def iceil(x: float) -> int: - return int(ceil(x)) + return ceil(x) # replacement for numpy.core.multiarray.arange, in the lack of numpy diff --git a/scal3/vcs_modules/git.py b/scal3/vcs_modules/git.py index e75b2efcd..8b1c5f61b 100644 --- a/scal3/vcs_modules/git.py +++ b/scal3/vcs_modules/git.py @@ -45,7 +45,7 @@ def getCommitList( branch="", ) -> "list[tuple[int, str]]": """ - returns a list of (epoch, commit_id) tuples. + Returns a list of (epoch, commit_id) tuples. this function is optimized for recent commits i.e. endJd is either None or recent