mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 04:19:18 +00:00
Implement NumPy 2.0 migration rule (#7702)
## Summary <!-- What's the purpose of the change? What does it do, and why? --> Hi! Currently NumPy Python API is undergoing a cleanup process that will be delivered in NumPy 2.0 (release is planned for the end of the year). Most changes are rather simple (renaming, removing or moving a member of the main namespace to a new place), and they could be flagged/fixed by an additional ruff rule for numpy (e.g. changing occurrences of `np.float_` to `np.float64`). Would you accept such rule? I named it `NPY201` in the existing group, so people will receive a heads-up for changes arriving in 2.0 before actually migrating to it. ~~This is still a draft PR.~~ I'm not an expert in rust so if any part of code can be done better please share! NumPy 2.0 migration guide: https://numpy.org/devdocs/numpy_2_0_migration_guide.html NEP 52: https://numpy.org/neps/nep-0052-python-api-cleanup.html NumPy cleanup tracking issue: https://github.com/numpy/numpy/issues/23999 ## Test Plan A unit test is provided that checks all rule's fix cases.
This commit is contained in:
parent
f64c389654
commit
d04d964ace
8 changed files with 1460 additions and 0 deletions
|
@ -859,6 +859,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> {
|
|||
(Numpy, "001") => (RuleGroup::Stable, rules::numpy::rules::NumpyDeprecatedTypeAlias),
|
||||
(Numpy, "002") => (RuleGroup::Stable, rules::numpy::rules::NumpyLegacyRandom),
|
||||
(Numpy, "003") => (RuleGroup::Stable, rules::numpy::rules::NumpyDeprecatedFunction),
|
||||
(Numpy, "201") => (RuleGroup::Preview, rules::numpy::rules::Numpy2Deprecation),
|
||||
|
||||
// ruff
|
||||
(Ruff, "001") => (RuleGroup::Stable, rules::ruff::rules::AmbiguousUnicodeCharacterString),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue