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

Deprecation warnings from numpy #1904

Closed
bje- opened this issue Dec 19, 2022 · 9 comments · Fixed by #1978
Closed

Deprecation warnings from numpy #1904

bje- opened this issue Dec 19, 2022 · 9 comments · Fixed by #1978
Labels
Enhancement ✨ Improvement to a component Good first issue Friendly and approachable by new contributors

Comments

@bje-
Copy link
Contributor

bje- commented Dec 19, 2022

Steps to reproduce

  1. Run pylint over the following test case:
"""Test case"""

import numpy as np
value = np.random.seed(1234)

Current behavior

/home/bje/source/nemo/myenv/lib/python3.10/site-packages/astroid/raw_building.py:470: FutureWarning: In the future `np.long` will be defined as the corresponding NumPy scalar.  (This may have returned Python scalars in past versions.
  getattr(sys.modules[modname], name)
/home/bje/source/nemo/myenv/lib/python3.10/site-packages/astroid/raw_building.py:470: FutureWarning: In the future `np.long` will be defined as the corresponding NumPy scalar.  (This may have returned Python scalars in past versions.
  getattr(sys.modules[modname], name)

Expected behavior

There should be no future warnings.

python -c "from astroid import pkginfo; print(pkginfo.version)" output

2.12.13

@Pierre-Sassoulas
Copy link
Member

This seems very similar to #1514 that was fixed in 2.12.0.

@Pierre-Sassoulas Pierre-Sassoulas added the Enhancement ✨ Improvement to a component label Dec 20, 2022
@bje-
Copy link
Contributor Author

bje- commented Dec 20, 2022

I'm running 2.12.13 (> 2.12.0), so the fix isn't working in this case?

@Pierre-Sassoulas
Copy link
Member

I don't know why #1514 did not fix this, I think we were capturing both stdout and stderr, so this will need some investigation. My guess would be that there's somewhere else to apply the same method to.

@duboise-cnes
Copy link

duboise-cnes commented Dec 22, 2022

Hello,
I see the same error with pylint on our tool demcompare. Pylint version:

pylint --version
pylint 2.15.9
astroid 2.12.13
Python 3.8.10 (default, Nov 14 2022, 12:59:47) 
[GCC 9.4.0]

I confirm the weird astroid lower warning and I don't know how to bypass it with pylint checking.

pylint demcompare 
/home/duboise/work/src/demcompare/venv/lib/python3.8/site-packages/astroid/raw_building.py:470: FutureWarning: In the future `np.long` will be defined as the corresponding NumPy scalar.  (This may have returned Python scalars in past versions.
  getattr(sys.modules[modname], name)
... (four times)

Thanks in advance if there is a solution
Cordially

@dfioravanti
Copy link

Thanks in advance if there is a solution

while annoying the warning does not make pylint fail. Just ignore it. In a CI you can just check pylint return code. It will return 0 as expected

@duboise-cnes
Copy link

I agree, even if annoying because it feels our code as a problem somewhere, the CI with pylint doesn't fail indeed. Thanks for the answer that confirm to not bother for now.

@bje-
Copy link
Contributor Author

bje- commented Dec 22, 2022

That might be fine in a CI environment, but for users, ultimately, ignoring warnings becomes difficult when there are too many such warnings. I would like to see this fixed.

@dfioravanti
Copy link

Oh, it was not an argument in favour of not fixing it. It was just to point out that it is not a breaking problem. It is "just" a lot of quite annoying warnings. I am following the issue because it annoys me too. So I am in the same "I hope they will fix it" boat

@jacobtylerwalls
Copy link
Member

I don't know why #1514 did not fix this, I think we were capturing both stdout and stderr, so this will need some investigation. My guess would be that there's somewhere else to apply the same method to.

That PR only addressed import-time. This FutureWarning is emitted by numpy's package-level __getattr__ method, not during import.

@jacobtylerwalls jacobtylerwalls added the Good first issue Friendly and approachable by new contributors label Dec 22, 2022
Pierre-Sassoulas added a commit that referenced this issue Jan 30, 2023
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component Good first issue Friendly and approachable by new contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants