summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Osvaldo Barrera <hugo@whynothugo.nl>2023-06-06 11:58:45 +0200
committerHugo Osvaldo Barrera <hugo@whynothugo.nl>2023-06-06 12:22:51 +0200
commitf22d4c124f3809fa47851ffecec583d9fbeaec8d (patch)
tree5757454a086e2281f31bc1b6df439a059078303f
parent642eecb79bde09669bbc2ed16dd1e27b9f2ee64d (diff)
Remove unnecessary .keys() when iterating dicts
This is likely a leftover from the Python 2 days.
-rw-r--r--khal/khalendar/backend.py6
-rw-r--r--khal/khalendar/event.py2
-rw-r--r--khal/settings/utils.py2
3 files changed, 5 insertions, 5 deletions
diff --git a/khal/khalendar/backend.py b/khal/khalendar/backend.py
index 55e1941b..34b1e1d0 100644
--- a/khal/khalendar/backend.py
+++ b/khal/khalendar/backend.py
@@ -272,7 +272,7 @@ class SQLiteDb:
self.deletelike(href + '%', calendar=calendar)
ical = cal_from_ics(vevent_str)
vcard = ical.walk()[0]
- for key in vcard.keys():
+ for key in vcard:
if key in ['BDAY', 'X-ANNIVERSARY', 'ANNIVERSARY'] or key.endswith('X-ABDATE'):
date = vcard[key]
uuid = vcard.get('UID')
@@ -674,11 +674,11 @@ def get_vcard_event_description(vcard: icalendar.cal.Component, key: str) -> str
return 'anniversary'
elif key.endswith('X-ABDATE'):
desc_key = key[:-8] + 'X-ABLABEL'
- if desc_key in vcard.keys():
+ if desc_key in vcard:
return vcard[desc_key]
else:
desc_key = key[:-8] + 'X-ABLabel'
- if desc_key in vcard.keys():
+ if desc_key in vcard:
return vcard[desc_key]
else:
return 'custom event from vcard'
diff --git a/khal/khalendar/event.py b/khal/khalendar/event.py
index bbafc4e6..8f2f0cf6 100644
--- a/khal/khalendar/event.py
+++ b/khal/khalendar/event.py
@@ -145,7 +145,7 @@ class Event:
vevents['PROTO'] = event
if ref is None:
- ref = 'PROTO' if ref in vevents.keys() else list(vevents.keys())[0]
+ ref = 'PROTO' if ref in vevents else list(vevents.keys())[0]
try:
if type(vevents[ref]['DTSTART'].dt) != type(vevents[ref]['DTEND'].dt): # noqa: E721
raise ValueError('DTSTART and DTEND should be of the same type (datetime or date)')
diff --git a/khal/settings/utils.py b/khal/settings/utils.py
index f01c26fd..8f93993c 100644
--- a/khal/settings/utils.py
+++ b/khal/settings/utils.py
@@ -131,7 +131,7 @@ def is_color(color: str) -> str:
# 4) a color index from the 256 color palette
# 5) an HTML-style color code
if (color in ['', 'auto'] or
- color in COLORS.keys() or
+ color in COLORS or
(color.isdigit() and int(color) >= 0 and int(color) <= 255) or
(color.startswith('#') and (len(color) in [4, 7, 9]) and
all(c in '01234567890abcdefABCDEF' for c in color[1:]))):