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

Numpy deprecations #2455

Closed
sbrugman opened this issue Feb 1, 2023 · 8 comments · Fixed by #2810
Closed

Numpy deprecations #2455

sbrugman opened this issue Feb 1, 2023 · 8 comments · Fixed by #2810
Labels
rule Implementing or modifying a lint rule

Comments

@sbrugman
Copy link
Contributor

sbrugman commented Feb 1, 2023

Numpy deprecated np.bool and other types in 1.20, which expired in the latest release 1.24.

Deprecated name Identical to NumPy scalar type names
numpy.bool bool numpy.bool_
numpy.int int numpy.int_ (default), numpy.int64, or numpy.int32
numpy.float float numpy.float64, numpy.float_, numpy.double (equivalent)
numpy.complex complex numpy.complex128, numpy.complex_, numpy.cdouble(equivalent)
numpy.object object numpy.object_
numpy.str str numpy.str_
numpy.long int numpy.int_ (C long), numpy.longlong (largest integer type)
numpy.unicode str numpy.unicode_

Would be great to be able to automatically flag and fix this. Seen it pass by in multiple projects:
apache/spark#37817
pandas-dev/pandas#39019
dylan-profiler/visions#184
plotly/plotly.py#4010
https://stackoverflow.com/questions/67779374/deprecationwarning-np-bool

@charliermarsh charliermarsh added the rule Implementing or modifying a lint rule label Feb 1, 2023
@charliermarsh
Copy link
Member

It might be reasonable to add these as an UP rule, since those codes are made up anyway given that pyupgrade isn't actually a Flake8 plugin.

@charliermarsh
Copy link
Member

Although it might be incorrect to "market" rules as part of pyupgrade when they're in fact not.

@ngnpope
Copy link
Contributor

ngnpope commented Feb 1, 2023

Use UPG for "upgrade"? Or UPN for "upgrade numpy"?

@charliermarsh
Copy link
Member

For now, if we did something like this, it's probably safest to put it in RUF or add a new category like RX that requires users to turn them on one-by-one.

@sbrugman
Copy link
Contributor Author

sbrugman commented Feb 1, 2023

For the future effort of reorganizing rules, we might group them per dependency (if any). Now we have pytest and pandas. For now I'd opt for flake8-numpy or just numpy with NPY. (This allows to add all future rules related to the package there too). RUF is also fine of course.

@charliermarsh
Copy link
Member

NPY is reasonable too, yeah.

@ngnpope
Copy link
Contributor

ngnpope commented Feb 1, 2023

NPY makes so much sense. Good shout.

@sbrugman
Copy link
Contributor Author

sbrugman commented Feb 2, 2023

Also relevant for mlflow/mlflow#4048

charliermarsh pushed a commit that referenced this issue Feb 14, 2023
Closes #2455

Used `NPY` as prefix code as agreed in the issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants