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

MNT Fix Python 3.12 deprecation warning #1518

Merged

Conversation

lesteve
Copy link
Member

@lesteve lesteve commented Oct 20, 2023

  • ast.Num is deprecated in Python 3.12
  • .n is deprecated in Python 3.12 and replaced by .value
ipython
Python 3.12.0 | packaged by conda-forge | (main, Oct  3 2023, 08:43:22) [GCC 12.3.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.16.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import ast

In [2]: ast.Num(3)
<ipython-input-2-42ae1b59512c>:1: DeprecationWarning: ast.Num is deprecated and will be removed in Python 3.14; use ast.Constant instead
  ast.Num(3)
Out[2]: <ast.Constant at 0x7f31a30d5850>

In [3]: ast.Num(3).n
<ipython-input-3-f0830cd35b24>:1: DeprecationWarning: ast.Num is deprecated and will be removed in Python 3.14; use ast.Constant instead
  ast.Num(3).n
<ipython-input-3-f0830cd35b24>:1: DeprecationWarning: Attribute n is deprecated and will be removed in Python 3.14; use value instead
  ast.Num(3).n
Out[3]: 3

Or https://docs.python.org/3/library/ast.html#node-classes

Deprecated since version 3.8: Old classes ast.Num, ast.Str, ast.Bytes, ast.NameConstant and ast.Ellipsis are still available, but they will be removed in future Python releases. In the meantime, instantiating them will return an instance of a different class.

cc @adrinjalali who has written this code I think 😉

Context: this was seen in scikit-learn CI when turning warnings into errors scikit-learn/scikit-learn#27627

Copy link
Contributor

@tomMoral tomMoral left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to wait until we merge #1515 dropping the support of python3.7. ^^

Otherwise LGTM!

edit: the PR has been merge :)

@tomMoral tomMoral closed this Oct 20, 2023
@tomMoral tomMoral reopened this Oct 20, 2023
@codecov
Copy link

codecov bot commented Oct 20, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (e787de8) 95.03% compared to head (fd62768) 94.98%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1518      +/-   ##
==========================================
- Coverage   95.03%   94.98%   -0.06%     
==========================================
  Files          45       45              
  Lines        7551     7551              
==========================================
- Hits         7176     7172       -4     
- Misses        375      379       +4     
Files Coverage Δ
joblib/_utils.py 95.45% <100.00%> (ø)

... and 5 files with indirect coverage changes

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

@tomMoral tomMoral merged commit 05caf07 into joblib:master Oct 20, 2023
16 checks passed
@lesteve lesteve deleted the remove-python-3.12-deprecation-warning branch February 2, 2024 16:54
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.

None yet

2 participants