Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow string_content to be a str #162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BoboTiG
Copy link
Member

@BoboTiG BoboTiG commented Feb 4, 2025

I was surprised to read the events() docstring stating:

:param string_content: iCal content as string

... While not being able to pass a str. Here is the error in this case:

Traceback (most recent call last):
  File "test.py", line 28, in <module>
    events = icalevents.events(
        string_content=ics,
    ...<3 lines>...
        sort=True,
    )
  File "/.../icalevents/icalevents.py", line 55, in events
    content = ical_download.data_from_string(string_content, apple_fix=fix_apple)
  File "/.../icalevents/icaldownload.py", line 91, in data_from_string
    return self.decode(string_content, apple_fix=apple_fix)
           ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../icalevents/icaldownload.py", line 103, in decode
    content = content.decode(encoding)
              ^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?

So here is a small patch to allow both bytes, and str.

Copy link

codecov bot commented Feb 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.90%. Comparing base (5dd30fe) to head (0659836).
Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #162      +/-   ##
==========================================
+ Coverage   91.88%   91.90%   +0.02%     
==========================================
  Files           4        4              
  Lines         382      383       +1     
  Branches       93       94       +1     
==========================================
+ Hits          351      352       +1     
  Misses         14       14              
  Partials       17       17              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@BoboTiG BoboTiG mentioned this pull request Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant