From 72f3a96560468bfa2c97e7f16d42f7ce4f32999f Mon Sep 17 00:00:00 2001 From: Adrian Moennich Date: Wed, 21 Aug 2024 11:20:39 +0200 Subject: [PATCH] Update ruff config (+ fix violations) --- livesync/indico_livesync/uploader.py | 4 ++-- piwik/indico_piwik/queries/utils.py | 10 +++++----- ruff.toml | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/livesync/indico_livesync/uploader.py b/livesync/indico_livesync/uploader.py index 3982781..8befec0 100644 --- a/livesync/indico_livesync/uploader.py +++ b/livesync/indico_livesync/uploader.py @@ -79,11 +79,11 @@ class Uploader: change_by_obj = {} for obj, change in records.items(): by_model[type(obj)].add(obj.id) - change_by_obj[type(obj), obj.id] = change + change_by_obj[(type(obj), obj.id)] = change rv = {} for model, ids in by_model.items(): for obj in self.backend.get_data_query(model, ids).yield_per(5000): - rv[obj] = change_by_obj[model, obj.id] + rv[obj] = change_by_obj[(model, obj.id)] assert len(records) == len(rv) return rv diff --git a/piwik/indico_piwik/queries/utils.py b/piwik/indico_piwik/queries/utils.py index 9ffed24..80df2b0 100644 --- a/piwik/indico_piwik/queries/utils.py +++ b/piwik/indico_piwik/queries/utils.py @@ -44,11 +44,11 @@ def stringify_seconds(seconds=0): """ seconds = int(seconds) minutes = seconds / 60 - ti = {'h': 0, 'm': 0, 's': 0} + h = m = s = 0 if seconds > 0: - ti['s'] = seconds % 60 - ti['m'] = minutes % 60 - ti['h'] = minutes / 60 + s = seconds % 60 + m = minutes % 60 + h = minutes / 60 - return '%dh %dm %ds' % (ti['h'], ti['m'], ti['s']) + return f'{h}h {m}m {s}s' diff --git a/ruff.toml b/ruff.toml index 8c9e8c4..35be148 100644 --- a/ruff.toml +++ b/ruff.toml @@ -159,6 +159,9 @@ allow-dunder-method-names = [ '__clause_element__', ] +[lint.ruff] +parenthesize-tuple-in-subscript = true + [lint.per-file-ignores] # allow stuff that's useful in tests '*/*_test.py' = ['E221', 'E241', 'E272', 'N802', 'S105', 'S106', 'PLC1901']