Skip to content

Commit

Permalink
Update NPY201 rule
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsokol committed Jun 27, 2024
1 parent 55f4812 commit 7b1a9b0
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 0 deletions.
24 changes: 24 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/numpy/NPY201.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,27 @@ def func():
np.cumproduct([1, 2, 3])

np.product([1, 2, 3])

np.trapz

np.in1d

np.AxisError

np.ComplexWarning

np.DTypePromotionError

np.ModuleDeprecationWarning

np.RankWarning

np.TooHardError

np.VisibleDeprecationWarning

np.compare_chararrays

np.chararray

np.format_parser
80 changes: 80 additions & 0 deletions crates/ruff_linter/src/rules/numpy/rules/numpy_2_0_deprecation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,86 @@ pub(crate) fn numpy_2_0_deprecation(checker: &mut Checker, expr: &Expr) {
compatibility: Compatibility::BackwardsCompatible,
},
}),
["numpy", "AxisError"] => Some(Replacement {
existing: "AxisError",
details: Details::AutoImport {
path: "numpy.exceptions",
name: "AxisError",
compatibility: Compatibility::BackwardsCompatible,
},
}),
["numpy", "ComplexWarning"] => Some(Replacement {
existing: "ComplexWarning",
details: Details::AutoImport {
path: "numpy.exceptions",
name: "ComplexWarning",
compatibility: Compatibility::BackwardsCompatible,
},
}),
["numpy", "DTypePromotionError"] => Some(Replacement {
existing: "DTypePromotionError",
details: Details::AutoImport {
path: "numpy.exceptions",
name: "DTypePromotionError",
compatibility: Compatibility::BackwardsCompatible,
},
}),
["numpy", "ModuleDeprecationWarning"] => Some(Replacement {
existing: "ModuleDeprecationWarning",
details: Details::AutoImport {
path: "numpy.exceptions",
name: "ModuleDeprecationWarning",
compatibility: Compatibility::BackwardsCompatible,
},
}),
["numpy", "RankWarning"] => Some(Replacement {
existing: "RankWarning",
details: Details::AutoImport {
path: "numpy.exceptions",
name: "RankWarning",
compatibility: Compatibility::Breaking,
},
}),
["numpy", "TooHardError"] => Some(Replacement {
existing: "TooHardError",
details: Details::AutoImport {
path: "numpy.exceptions",
name: "TooHardError",
compatibility: Compatibility::BackwardsCompatible,
},
}),
["numpy", "VisibleDeprecationWarning"] => Some(Replacement {
existing: "VisibleDeprecationWarning",
details: Details::AutoImport {
path: "numpy.exceptions",
name: "VisibleDeprecationWarning",
compatibility: Compatibility::BackwardsCompatible,
},
}),
["numpy", "compare_chararrays"] => Some(Replacement {
existing: "compare_chararrays",
details: Details::AutoImport {
path: "numpy.char",
name: "compare_chararrays",
compatibility: Compatibility::BackwardsCompatible,
},
}),
["numpy", "chararray"] => Some(Replacement {
existing: "chararray",
details: Details::AutoImport {
path: "numpy.char",
name: "chararray",
compatibility: Compatibility::BackwardsCompatible,
},
}),
["numpy", "format_parser"] => Some(Replacement {
existing: "format_parser",
details: Details::AutoImport {
path: "numpy.rec",
name: "format_parser",
compatibility: Compatibility::BackwardsCompatible,
},
}),
_ => None,
});

Expand Down

0 comments on commit 7b1a9b0

Please sign in to comment.