Skip to content

Commit

Permalink
probable bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
McLaynV committed Jan 11, 2025
1 parent 03e32e9 commit c657791
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/icalendar/cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ def from_ical(cls, st, multiple=False):
'Found no components where exactly one is required', st))
return comps[0]

@staticmethod
def _format_error(error_description, bad_input, elipsis='[...]'):
# there's three character more in the error, ie. ' ' x2 and a ':'
max_error_length = 100 - 3
Expand Down
6 changes: 4 additions & 2 deletions src/icalendar/parser_tools.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Union
from typing import List, Union

SEQUENCE_TYPES = (list, tuple)
DEFAULT_ENCODING = 'utf-8'
Expand Down Expand Up @@ -35,7 +35,9 @@ def to_unicode(value: ICAL_TYPE, encoding='utf-8-sig') -> str:
return value


def data_encode(data: Union[ICAL_TYPE, dict, list], encoding=DEFAULT_ENCODING) -> bytes:
def data_encode(
data: Union[ICAL_TYPE, dict, list], encoding=DEFAULT_ENCODING
) -> Union[bytes, List[bytes], dict]:
"""Encode all datastructures to the given encoding.
Currently unicode strings, dicts and lists are supported.
"""
Expand Down
4 changes: 2 additions & 2 deletions src/icalendar/tests/fuzzed/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def fuzz_calendar_v1(
cal = [cal]
for c in cal:
if should_walk:
for event in cal.walk("VEVENT"):
for event in c.walk("VEVENT"):
event.to_ical()
else:
cal.to_ical()
c.to_ical()
2 changes: 1 addition & 1 deletion src/icalendar/tests/prop/test_windows_to_olson_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_windows_timezone(tzp):
"""Test that the timezone is mapped correctly to olson."""
dt = vDatetime.from_ical("20170507T181920", "Eastern Standard Time")
expected = tzp.localize(datetime(2017, 5, 7, 18, 19, 20), "America/New_York")
assert dt.tzinfo == dt.tzinfo
assert dt.tzinfo == expected.tzinfo
assert dt == expected


Expand Down
2 changes: 1 addition & 1 deletion src/icalendar/tests/test_issue_722_generate_vtimezone.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_conversion_converges(tzp, tzid):
tzinfo2 = generated1.to_tz()
generated2 = Timezone.from_tzinfo(tzinfo2, "test-generated")
tzinfo3 = generated2.to_tz()
generated3 = Timezone.from_tzinfo(tzinfo2, "test-generated")
generated3 = Timezone.from_tzinfo(tzinfo3, "test-generated")
# pprint(generated1.get_transitions())
# pprint(generated2.get_transitions())
assert_components_equal(generated1, generated2)
Expand Down
4 changes: 2 additions & 2 deletions src/icalendar/timezone/equivalent_timezone_ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from pathlib import Path
from pprint import pprint
from time import time
from typing import Callable, NamedTuple, Optional
from typing import Callable, NamedTuple, Optional, Any, Tuple, List

from zoneinfo import ZoneInfo, available_timezones

Expand All @@ -30,7 +30,7 @@
def check(dt, tz:tzinfo):
return (dt, tz.utcoffset(dt))

def checks(tz:tzinfo) -> tuple:
def checks(tz:tzinfo) -> List[Tuple[Any, Optional[timedelta]]]:
result = []
for dt in DTS:
try:
Expand Down

0 comments on commit c657791

Please sign in to comment.