Skip to content

Commit d99ec4a

Browse files
Revert "Apply code formatting with tox -e ruff as requested in review feedback"
This reverts commit 673b9a1.
1 parent 228f4bc commit d99ec4a

38 files changed

Lines changed: 306 additions & 276 deletions

bootstrap.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import shutil
2323
import sys
2424
import tempfile
25+
2526
from optparse import OptionParser
2627

2728
tmpeggs = tempfile.mkdtemp()
@@ -59,7 +60,7 @@
5960
parser.add_option(
6061
"-c",
6162
"--config-file",
62-
help=("Specify the path to the buildout configuration file to be used."),
63+
help=("Specify the path to the buildout configuration " "file to be used."),
6364
)
6465
parser.add_option(
6566
"-f", "--find-links", help=("Specify a URL to search for buildout releases")
@@ -79,8 +80,8 @@
7980

8081
try:
8182
if options.allow_site_packages:
82-
import pkg_resources
8383
import setuptools
84+
import pkg_resources
8485
from urllib.request import urlopen
8586
except ImportError:
8687
from urllib2 import urlopen
@@ -102,8 +103,8 @@
102103

103104
setup_args = {"to_dir": tmpeggs, "download_delay": 0}
104105
ez["use_setuptools"](**setup_args)
105-
import pkg_resources
106106
import setuptools
107+
import pkg_resources
107108

108109
# This does not (always?) update the default working set. We will
109110
# do it.
@@ -171,13 +172,13 @@ def _final_version(parsed_version):
171172
best.sort()
172173
version = best[-1].version
173174
if version:
174-
requirement = f"{requirement}=={version}"
175+
requirement = "==".join((requirement, version))
175176
cmd.append(requirement)
176177

177178
import subprocess
178179

179180
if subprocess.call(cmd, env=dict(os.environ, PYTHONPATH=setuptools_path)) != 0:
180-
raise Exception(f"Failed to execute command:\n{repr(cmd)[1:-1]}")
181+
raise Exception("Failed to execute command:\n%s" % repr(cmd)[1:-1])
181182

182183
######################################################################
183184
# Import and run buildout

src/icalendar/alarms.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from __future__ import annotations
1515

1616
from datetime import date, timedelta, tzinfo
17-
from typing import TYPE_CHECKING, Generator, Union
17+
from typing import TYPE_CHECKING, Generator, Optional, Union
1818

1919
from icalendar.cal.event import Event
2020
from icalendar.cal.todo import Todo
@@ -42,9 +42,9 @@ def __init__(
4242
self,
4343
alarm: Alarm,
4444
trigger: datetime,
45-
acknowledged_until: datetime | None = None,
46-
snoozed_until: datetime | None = None,
47-
parent: Parent | None = None,
45+
acknowledged_until: Optional[datetime] = None,
46+
snoozed_until: Optional[datetime] = None,
47+
parent: Optional[Parent] = None,
4848
):
4949
"""Create a new AlarmTime.
5050
@@ -75,7 +75,7 @@ def __init__(
7575
self._snooze_until = snoozed_until
7676

7777
@property
78-
def acknowledged(self) -> datetime | None:
78+
def acknowledged(self) -> Optional[datetime]:
7979
"""The time in UTC at which this alarm was last acknowledged.
8080
8181
If the alarm was not acknowledged (dismissed), then this is None.
@@ -93,7 +93,7 @@ def alarm(self) -> Alarm:
9393
return self._alarm
9494

9595
@property
96-
def parent(self) -> Parent | None:
96+
def parent(self) -> Optional[Parent]:
9797
"""This is the component that contains the alarm.
9898
9999
This is None if you did not use Alarms.set_component().
@@ -178,17 +178,17 @@ class Alarms:
178178
This is not implemented yet.
179179
"""
180180

181-
def __init__(self, component: Alarm | Event | Todo | None = None):
181+
def __init__(self, component: Optional[Alarm | Event | Todo] = None):
182182
"""Start computing alarm times."""
183183
self._absolute_alarms: list[Alarm] = []
184184
self._start_alarms: list[Alarm] = []
185185
self._end_alarms: list[Alarm] = []
186-
self._start: date | None = None
187-
self._end: date | None = None
188-
self._parent: Parent | None = None
189-
self._last_ack: datetime | None = None
190-
self._snooze_until: datetime | None = None
191-
self._local_tzinfo: tzinfo | None = None
186+
self._start: Optional[date] = None
187+
self._end: Optional[date] = None
188+
self._parent: Optional[Parent] = None
189+
self._last_ack: Optional[datetime] = None
190+
self._snooze_until: Optional[datetime] = None
191+
self._local_tzinfo: Optional[tzinfo] = None
192192

193193
if component is not None:
194194
self.add_component(component)
@@ -234,15 +234,15 @@ def add_alarm(self, alarm: Alarm) -> None:
234234
else:
235235
self._end_alarms.append(alarm)
236236

237-
def set_start(self, dt: date | None):
237+
def set_start(self, dt: Optional[date]):
238238
"""Set the start of the component.
239239
240240
If you have only absolute alarms, this is not required.
241241
If you have alarms relative to the start of a compoment, set the start here.
242242
"""
243243
self._start = dt
244244

245-
def set_end(self, dt: date | None):
245+
def set_end(self, dt: Optional[date]):
246246
"""Set the end of the component.
247247
248248
If you have only absolute alarms, this is not required.
@@ -258,7 +258,7 @@ def _add(self, dt: date, td: timedelta):
258258
dt = to_datetime(dt)
259259
return normalize_pytz(dt + td)
260260

261-
def acknowledge_until(self, dt: date | None) -> None:
261+
def acknowledge_until(self, dt: Optional[date]) -> None:
262262
"""This is the time in UTC when all the alarms of this component were acknowledged.
263263
264264
Only the last call counts.
@@ -271,7 +271,7 @@ def acknowledge_until(self, dt: date | None) -> None:
271271
"""
272272
self._last_ack = tzp.localize_utc(dt) if dt is not None else None
273273

274-
def snooze_until(self, dt: date | None) -> None:
274+
def snooze_until(self, dt: Optional[date]) -> None:
275275
"""This is the time in UTC when all the alarms of this component were snoozed.
276276
277277
Only the last call counts.
@@ -281,7 +281,7 @@ def snooze_until(self, dt: date | None) -> None:
281281
"""
282282
self._snooze_until = tzp.localize_utc(dt) if dt is not None else None
283283

284-
def set_local_timezone(self, tzinfo: tzinfo | str | None):
284+
def set_local_timezone(self, tzinfo: Optional[tzinfo | str]):
285285
"""Set the local timezone.
286286
287287
Events are sometimes in local time.

src/icalendar/attr.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def _get_rrules(self: Component) -> list[vRecur]:
311311

312312

313313
def multi_language_text_property(
314-
main_prop: str, compatibility_prop: str | None, doc: str
314+
main_prop: str, compatibility_prop: Optional[str], doc: str
315315
) -> property:
316316
"""This creates a text property.
317317
@@ -323,7 +323,7 @@ def multi_language_text_property(
323323
doc (str): The documentation string
324324
"""
325325

326-
def fget(self: Component) -> str | None:
326+
def fget(self: Component) -> Optional[str]:
327327
"""Get the property"""
328328
result = self.get(main_prop)
329329
if result is None and compatibility_prop is not None:
@@ -334,7 +334,7 @@ def fget(self: Component) -> str | None:
334334
return item
335335
return result
336336

337-
def fset(self: Component, value: str | None):
337+
def fset(self: Component, value: Optional[str]):
338338
"""Set the property."""
339339
fdel(self)
340340
if value is not None:
@@ -365,7 +365,7 @@ def fget(self: Component) -> int:
365365
except ValueError as e:
366366
raise InvalidCalendar(f"{prop} must be an int") from e
367367

368-
def fset(self: Component, value: int | None):
368+
def fset(self: Component, value: Optional[int]):
369369
"""Set the property."""
370370
fdel(self)
371371
if value is not None:
@@ -393,7 +393,7 @@ def single_utc_property(name: str, docs: str) -> property:
393393
+ docs
394394
)
395395

396-
def fget(self: Component) -> datetime | None:
396+
def fget(self: Component) -> Optional[datetime]:
397397
"""Get the value."""
398398
if name not in self:
399399
return None
@@ -407,7 +407,7 @@ def fget(self: Component) -> datetime | None:
407407
raise InvalidCalendar(f"{name} must be a datetime in UTC, not {value}")
408408
return tzp.localize_utc(value)
409409

410-
def fset(self: Component, value: datetime | None):
410+
def fset(self: Component, value: Optional[datetime]):
411411
"""Set the value"""
412412
if value is None:
413413
fdel(self)
@@ -425,7 +425,7 @@ def fdel(self: Component):
425425

426426

427427
def single_string_property(
428-
name: str, docs: str, other_name: str | None = None, default: str = ""
428+
name: str, docs: str, other_name: Optional[str] = None, default: str = ""
429429
) -> property:
430430
"""Create a property to access a single string value."""
431431

@@ -440,7 +440,7 @@ def fget(self: Component) -> str:
440440
return result[0]
441441
return result
442442

443-
def fset(self: Component, value: str | None):
443+
def fset(self: Component, value: Optional[str]):
444444
"""Set the value.
445445
446446
Setting the value to None will delete it.
@@ -560,7 +560,7 @@ def fdel(self: Component):
560560

561561
def _get_categories(component: Component) -> list[str]:
562562
"""Get all the categories."""
563-
categories: vCategory | list[vCategory] | None = component.get("CATEGORIES")
563+
categories: Optional[vCategory | list[vCategory]] = component.get("CATEGORIES")
564564
if isinstance(categories, list):
565565
_set_categories(
566566
component,
@@ -573,7 +573,7 @@ def _get_categories(component: Component) -> list[str]:
573573
return categories.cats
574574

575575

576-
def _set_categories(component: Component, cats: Sequence[str] | None) -> None:
576+
def _set_categories(component: Component, cats: Optional[Sequence[str]]) -> None:
577577
"""Set the categories."""
578578
if not cats and cats != []:
579579
_del_categories(component)
@@ -871,7 +871,7 @@ def _del_attendees(self: Component):
871871

872872
def create_single_property(
873873
prop: str,
874-
value_attr: str | None,
874+
value_attr: Optional[str],
875875
value_type: tuple[type],
876876
type_def: type,
877877
doc: str,
@@ -945,7 +945,7 @@ def p_del(self: Component):
945945
)
946946

947947

948-
def property_get_duration(self: Component) -> timedelta | None:
948+
def property_get_duration(self: Component) -> Optional[timedelta]:
949949
"""Getter for property DURATION."""
950950
default = object()
951951
duration = self.get("duration", default)
@@ -960,7 +960,7 @@ def property_get_duration(self: Component) -> timedelta | None:
960960
return None
961961

962962

963-
def property_set_duration(self: Component, value: timedelta | None):
963+
def property_set_duration(self: Component, value: Optional[timedelta]):
964964
"""Setter for property DURATION."""
965965
if value is None:
966966
self.pop("duration", None)
@@ -1015,7 +1015,7 @@ def fget(self: Component) -> list[str]:
10151015
return [descriptions]
10161016
return descriptions
10171017

1018-
def fset(self: Component, values: str | Sequence[str] | None):
1018+
def fset(self: Component, values: Optional[str | Sequence[str]]):
10191019
"""Set the values."""
10201020
fdel(self)
10211021
if values is None:
@@ -1087,7 +1087,7 @@ def fdel(self: Component):
10871087
)
10881088

10891089

1090-
def _get_organizer(self: Component) -> vCalAddress | None:
1090+
def _get_organizer(self: Component) -> Optional[vCalAddress]:
10911091
"""ORGANIZER defines the organizer for a calendar component.
10921092
10931093
Property Parameters:
@@ -1126,7 +1126,7 @@ def _get_organizer(self: Component) -> vCalAddress | None:
11261126
return self.get("ORGANIZER")
11271127

11281128

1129-
def _set_organizer(self: Component, value: vCalAddress | str | None):
1129+
def _set_organizer(self: Component, value: Optional[vCalAddress | str]):
11301130
"""Set the value."""
11311131
_del_organizer(self)
11321132
if value is not None:
@@ -1448,7 +1448,7 @@ def timezone_datetime_property(name: str, docs: str):
14481448

14491449

14501450
@property
1451-
def rfc_7953_duration_property(self) -> timedelta | None:
1451+
def rfc_7953_duration_property(self) -> Optional[timedelta]:
14521452
"""Compute the duration of this component.
14531453
14541454
If there is no :attr:`DTEND` or :attr:`DURATION` set, this is None.
@@ -1471,7 +1471,7 @@ def rfc_7953_duration_property(self) -> timedelta | None:
14711471

14721472

14731473
@property
1474-
def rfc_7953_end_property(self) -> timedelta | None:
1474+
def rfc_7953_end_property(self) -> Optional[timedelta]:
14751475
"""Compute the duration of this component.
14761476
14771477
If there is no :attr:`DTEND` or :attr:`DURATION` set, this is None.

src/icalendar/cal/alarm.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,10 @@ def triggers(self):
246246
def new(
247247
cls,
248248
/,
249-
attendees: list[vCalAddress] | None = None,
250-
description: str | None = None,
251-
summary: str | None = None,
252-
uid: str | uuid.UUID | None = None,
249+
attendees: Optional[list[vCalAddress]] = None,
250+
description: Optional[str] = None,
251+
summary: Optional[str] = None,
252+
uid: Optional[str | uuid.UUID] = None,
253253
):
254254
"""Create a new alarm with all required properties.
255255

src/icalendar/cal/availability.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import uuid
99
from datetime import datetime
10-
from typing import TYPE_CHECKING, Sequence
10+
from typing import TYPE_CHECKING, Optional, Sequence
1111

1212
from icalendar.attr import (
1313
busy_type_property,
@@ -234,25 +234,25 @@ def available(self) -> list[Available]:
234234
def new(
235235
cls,
236236
/,
237-
busy_type: BUSYTYPE | None = None,
237+
busy_type: Optional[BUSYTYPE] = None,
238238
categories: Sequence[str] = (),
239239
comments: list[str] | str | None = None,
240240
components: Sequence[Available] | None = (),
241241
contacts: list[str] | str | None = None,
242-
created: date | None = None,
243-
classification: CLASS | None = None,
244-
description: str | None = None,
245-
end: datetime | None = None,
246-
last_modified: date | None = None,
247-
location: str | None = None,
248-
organizer: vCalAddress | str | None = None,
249-
priority: int | None = None,
250-
sequence: int | None = None,
251-
stamp: date | None = None,
252-
start: datetime | None = None,
253-
summary: str | None = None,
254-
uid: str | uuid.UUID | None = None,
255-
url: str | None = None,
242+
created: Optional[date] = None,
243+
classification: Optional[CLASS] = None,
244+
description: Optional[str] = None,
245+
end: Optional[datetime] = None,
246+
last_modified: Optional[date] = None,
247+
location: Optional[str] = None,
248+
organizer: Optional[vCalAddress | str] = None,
249+
priority: Optional[int] = None,
250+
sequence: Optional[int] = None,
251+
stamp: Optional[date] = None,
252+
start: Optional[datetime] = None,
253+
summary: Optional[str] = None,
254+
uid: Optional[str | uuid.UUID] = None,
255+
url: Optional[str] = None,
256256
):
257257
"""Create a new event with all required properties.
258258

0 commit comments

Comments
 (0)