Skip to content

ValueError: Invalid isoformat string: '2025-02-13T23:04:11.000+0000' #191

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

Open
ovizii opened this issue Feb 14, 2025 · 2 comments
Open

ValueError: Invalid isoformat string: '2025-02-13T23:04:11.000+0000' #191

ovizii opened this issue Feb 14, 2025 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@ovizii
Copy link

ovizii commented Feb 14, 2025

Description of the bug
Trying to download docs from TR and getting this error:

To Reproduce
Steps to reproduce the behavior:

/app/bin/python3 pytr dl_docs /documents

Expected behavior
I expect the process to download all documents.

Error log

10:44:42 Subscribing #25 timeline activity log
10:44:42 Received #25 timeline activity log
10:44:42 Received last relevant timeline activity log
10:44:43 All timeline details requested
10:44:43    1/6092: HEM -- None - 2025-02-14T07:46:12
10:44:44    2/6092: Backhaus Bickert -- None - 2025-02-14T09:24:13
10:44:44    3/6092: OpenAI -- None - 2025-02-12T18:30:13
10:44:44    4/6092: EDEKA -- None - 2025-02-14T09:22:56
10:44:44    5/6092: Steuerkorrektur -- None - 2025-02-13T23:04:11
Traceback (most recent call last):
  File "/app/bin/pytr", line 8, in <module>
    sys.exit(main())
  File "/app/lib/python3.9/site-packages/pytr/main.py", line 267, in main
    asyncio.get_event_loop().run_until_complete(dl.dl_loop())
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/app/lib/python3.9/site-packages/pytr/dl.py", line 81, in dl_loop
    self.tl.process_timelineDetail(response, self)
  File "/app/lib/python3.9/site-packages/pytr/timeline.py", line 168, in process_timelineDetail
    dl.dl_doc(doc, title, doc.get("detail"), subfolder, datetime.fromisoformat(event["timestamp"]))
ValueError: Invalid isoformat string: '2025-02-13T23:04:11.000+0000'

Environment

  • OS: Docker with python:3.9-alpine
  • pytr version: python:3.9-alpine

Additional context
Dockerfile created with:

RUN         python3 -m venv /app &&\
            /app/bin/pip install pytr websockets &&\
            addgroup -g ${GID} -S ${USER} &&\
            adduser -u ${UID} -S ${USER} -G ${USER} &&\
            chown -R ${UID}:${GID} /app

@ovizii ovizii added the bug Something isn't working label Feb 14, 2025
@NiklasRosenstein
Copy link
Collaborator

NiklasRosenstein commented Feb 14, 2025

Curious, the string is a valid ISO8601 string. But Python 3.10 and earlier have trouble parsing it.

docker run --rm python:3.12-alpine python -c 'from datetime import datetime; print(datetime.fromisoformat("2025-02-13T23:04:11.000+0000"))'
2025-02-13 23:04:11+00:00docker run --rm python:3.11-alpine python -c 'from datetime import datetime; print(datetime.fromisoformat("2025-02-13T23:04:11.000+0000"))'
2025-02-13 23:04:11+00:00docker run --rm python:3.10-alpine python -c 'from datetime import datetime; print(datetime.fromisoformat("2025-02-13T23:04:11.000+0000"))'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ValueError: Invalid isoformat string: '2025-02-13T23:04:11.000+0000'docker run --rm python:3.9-alpine python -c 'from datetime import datetime; print(datetime.fromisoformat("2025-02-13T23:04:11.000+0000"))'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ValueError: Invalid isoformat string: '2025-02-13T23:04:11.000+0000'

3.10 docs say (https://docs.python.org/3.10/library/datetime.html#datetime.datetime.fromisoformat):

Caution

This does not support parsing arbitrary ISO 8601 strings - it is only intended as the inverse operation of datetime.isoformat(). A more full-featured ISO 8601 parser, dateutil.parser.isoparse is available in the third-party package dateutil.

3.11 docs say (https://docs.python.org/3.11/library/datetime.html#datetime.datetime.fromisoformat):

Changed in version 3.11: Previously, this method only supported formats that could be emitted by date.isoformat() or datetime.isoformat().

So unless we want to drop Python 3.9 and 3.10 support (which, I think, would not be a big deal, especially with the updated instructions to invoke pytr with uv), we'd need to use the python-dateutil package.

As an immediate workaround, you can start by using a more modern Python version @ovizii

@NiklasRosenstein NiklasRosenstein self-assigned this Feb 14, 2025
@ovizii
Copy link
Author

ovizii commented Feb 14, 2025

Thanks for the suggestion. I only went back to python:3.9-alpine as a workaround for a recent pytr issue which has meanwhile been solved and forgot to go back. I just tested with python:3.9-alpine and it works.

Feel free to close this ticket anytime you like. I've left it open if you liek to use it as a reminder about dropping support for Python 3.9 and 3.10 support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants