Skip to content

Commit

Permalink
remove unneeded .keys() calls
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Oct 10, 2024
1 parent 585b839 commit 3005f0a
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion scal3/cal_types/hijri.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def getMonthLenList(self):
)
for index, ym in enumerate(
sorted(
self.monthLenByYm.keys(),
self.monthLenByYm,
),
)
]
Expand Down
2 changes: 1 addition & 1 deletion scal3/event_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1897,7 +1897,7 @@ def getRulesHash(self) -> int:
)

def getRuleNames(self) -> list[str]:
return list(self.rulesOd.keys())
return list(self.rulesOd)

def addRule(self, rule: "EventRule") -> None:
self.rulesOd[rule.name] = rule
Expand Down
2 changes: 1 addition & 1 deletion scal3/locale_man.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ def numDecode(numSt: str) -> int:
with suppress(ValueError):
return int(numSt)
numSt = toStr(numSt)
tryLangs = list(digits.keys())
tryLangs = list(digits)
if langSh in digits:
tryLangs.remove(langSh)
tryLangs.insert(0, langSh)
Expand Down
2 changes: 1 addition & 1 deletion scal3/plugin_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def getAttr(moduleName, attr, default=None, absolute=False):
if not absolute:
moduleName = "scal3." + moduleName
# module = __import__(moduleName, fromlist=["__plugin_api_get__", attr])
# log.debug(sorted(sys.modules.keys()))
# log.debug(sorted(sys.modules))
module = sys.modules[moduleName]
allowed = getattr(module, "__plugin_api_get__", [])
if attr not in allowed:
Expand Down
6 changes: 3 additions & 3 deletions scal3/ui_gtk/event/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def updateTableViewType(self, viewType, hashBefore, hashAfter):
if viewType == "Change Table":
if hashBefore:
diff = self.extractChangeDiff(hashBefore, hashAfter)
for key in sorted(diff.keys()):
for key in sorted(diff):
(valueBefore, valueAfter) = diff[key]
treeModel.append(
[modifySymbol, key, str(valueBefore), str(valueAfter)],
Expand Down Expand Up @@ -415,7 +415,7 @@ def extractFullTable(self, hashBefore, hashAfter):
dataBefore = self.getObjectData(hashBefore)
dataAfter = self.getObjectData(hashAfter)
dataFull = [] # (symbol, key, valueBefore, valueAfter)
keys = sorted(set(dataBefore.keys()).union(dataAfter.keys()))
keys = sorted(set(dataBefore).union(dataAfter))
for key in keys:
valueBefore = dataBefore.get(key, "")
valueAfter = dataAfter.get(key, "")
Expand All @@ -442,7 +442,7 @@ def extractFullTable(self, hashBefore, hashAfter):
def extractChangeSummary(diff):
"""diff: dict: param -> (valueBefore, valueAfter)."""
if len(diff) < 3:
return ", ".join(diff.keys())
return ", ".join(diff)

return _("{count} parameters").format(count=_(len(diff)))

Expand Down
2 changes: 1 addition & 1 deletion scal3/ui_gtk/mainwin_items/weekCal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1347,7 +1347,7 @@ def __init__(self, win):
MoonStatusColumn(self),
]
defaultItemsDict = {item.objName: item for item in defaultItems}
itemNames = list(defaultItemsDict.keys())
itemNames = list(defaultItemsDict)
for name, enable in ui.wcalItems:
item = defaultItemsDict.get(name)
if item is None:
Expand Down
2 changes: 1 addition & 1 deletion scal3/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def __init__(
if isinstance(arg, list | tuple):
self.keyList = [item[0] for item in arg]
elif isinstance(arg, dict):
self.keyList = sorted(arg.keys())
self.keyList = sorted(arg)
else:
raise TypeError(
f"StrOrderedDict: bad type for first argument: {type(arg)}",
Expand Down
2 changes: 1 addition & 1 deletion tools/afghanistan-events.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
with open(jsonPath, encoding="utf-8") as jsonFile:
data = json.load(jsonFile)

# print(list(data.keys()))
# print(list(data))
# print(data['Irregular Recurring'])

calTypes = {
Expand Down

0 comments on commit 3005f0a

Please sign in to comment.