Skip to content

Ignore DeprecationWarnings for datetime.utcnow() #265

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

Merged
merged 1 commit into from
Jul 7, 2023

Conversation

ellert
Copy link
Contributor

@ellert ellert commented Jul 7, 2023

It is deprecated in Python 3.12.
The call that causes the warning is in jupyter_client. This causes 56 tests to fail. First failure is:

_______________________________ test_get_magics ________________________________
    def test_get_magics():
>       kernel = get_kernel()
/builddir/build/BUILD/metakernel-0.29.4/metakernel/tests/test_magic.py:35: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /builddir/build/BUILD/metakernel-0.29.4/metakernel/tests/utils.py:84: in get_kernel
    kernel = kernel_class(session=ss.Session(), iopub_socket=iopub_socket,
/usr/lib/python3.12/site-packages/jupyter_client/session.py:568: in __init__
    self._check_packers()
/usr/lib/python3.12/site-packages/jupyter_client/session.py:634: in _check_packers
    msg_datetime = dict(t=utcnow())
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    def utcnow() -> datetime:
        """Return timezone-aware UTC timestamp"""
>       return datetime.utcnow().replace(tzinfo=utc)
E       DeprecationWarning: datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.now(datetime.UTC).
/usr/lib/python3.12/site-packages/jupyter_client/session.py:203: DeprecationWarning

It is deprecated in Python 3.12.
The call that causes the warning is in jupyter_client.
This causes 56 tests to fail. First failure is:

_______________________________ test_get_magics ________________________________
    def test_get_magics():
>       kernel = get_kernel()
/builddir/build/BUILD/metakernel-0.29.4/metakernel/tests/test_magic.py:35:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/builddir/build/BUILD/metakernel-0.29.4/metakernel/tests/utils.py:84: in get_kernel
    kernel = kernel_class(session=ss.Session(), iopub_socket=iopub_socket,
/usr/lib/python3.12/site-packages/jupyter_client/session.py:568: in __init__
    self._check_packers()
/usr/lib/python3.12/site-packages/jupyter_client/session.py:634: in _check_packers
    msg_datetime = dict(t=utcnow())
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    def utcnow() -> datetime:
        """Return timezone-aware UTC timestamp"""
>       return datetime.utcnow().replace(tzinfo=utc)
E       DeprecationWarning: datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.now(datetime.UTC).
/usr/lib/python3.12/site-packages/jupyter_client/session.py:203: DeprecationWarning
@blink1073
Copy link
Contributor

Thanks!

@blink1073 blink1073 merged commit 7fd364a into Calysto:main Jul 7, 2023
@blink1073
Copy link
Contributor

I'll make a new release early next week.

@ellert ellert deleted the utcnow-warn-py-3.12 branch July 8, 2023 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants