You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When importing jsii in Python 3.12, and specifying to raise warnings as error (normally done as part of testing, not in production), you'll get a deprecation warning raised from dateutil.parser:
DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
Expected Behavior
No deprecation warnings raised when using jsii
Current Behavior
Python raises warning
Reproduction Steps
Install jsii with Python 3.12. Then run:
python -W error -c 'import jsii'
Output:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/tmp/repro-jsii/venv/lib/python3.12/site-packages/jsii/__init__.py", line 5, in <module>
from ._runtime import (
File "/private/tmp/repro-jsii/venv/lib/python3.12/site-packages/jsii/_runtime.py", line 20, in <module>
from . import _reference_map
File "/private/tmp/repro-jsii/venv/lib/python3.12/site-packages/jsii/_reference_map.py", line 5, in <module>
from ._kernel.types import ObjRef
File "/private/tmp/repro-jsii/venv/lib/python3.12/site-packages/jsii/_kernel/__init__.py", line 16, in <module>
from .providers import BaseProvider, ProcessProvider
File "/private/tmp/repro-jsii/venv/lib/python3.12/site-packages/jsii/_kernel/providers/__init__.py", line 2, in <module>
from .process import ProcessProvider
File "/private/tmp/repro-jsii/venv/lib/python3.12/site-packages/jsii/_kernel/providers/process.py", line 20, in <module>
import dateutil.parser
File "/private/tmp/repro-jsii/venv/lib/python3.12/site-packages/dateutil/parser/__init__.py", line 2, in <module>
from ._parser import parse, parser, parserinfo, ParserError
File "/private/tmp/repro-jsii/venv/lib/python3.12/site-packages/dateutil/parser/_parser.py", line 50, in <module>
from .. import tz
File "/private/tmp/repro-jsii/venv/lib/python3.12/site-packages/dateutil/tz/__init__.py", line 2, in <module>
from .tz import *
File "/private/tmp/repro-jsii/venv/lib/python3.12/site-packages/dateutil/tz/tz.py", line 37, in <module>
EPOCH = datetime.datetime.utcfromtimestamp(0)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
Possible Solution
jsii depends on dateutil.parser.isoparse (docs) to parse $jsii.date:
This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
Describe the bug
When importing
jsii
in Python 3.12, and specifying to raise warnings as error (normally done as part of testing, not in production), you'll get a deprecation warning raised fromdateutil.parser
:DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
Expected Behavior
No deprecation warnings raised when using
jsii
Current Behavior
Python raises warning
Reproduction Steps
Install
jsii
with Python 3.12. Then run:Output:
Possible Solution
jsii
depends ondateutil.parser.isoparse
(docs) to parse$jsii.date
:jsii/packages/@jsii/python-runtime/src/jsii/_kernel/providers/process.py
Line 133 in 62d2d37
This is the only use of dateutil. Also, dateutil hasn't been updated since July 2021.
Based on this doc it seems to be a fixed format being parsed, i.e. no need to use a parser that handles different formats:
jsii/gh-pages/content/specification/2-type-system.md
Lines 229 to 241 in 62d2d37
So
dateutil.parser
could potentially be removed as a dependency, and replaced with the standard librarydatetime.datetime.strptime
method.Additional Information/Context
No response
SDK version used
jsii 1.94.0
Environment details (OS name and version, etc.)
MacOS, Python 3.12.0
The text was updated successfully, but these errors were encountered: