Skip to content

Commit 6660b11

Browse files
authored
[pyupgrade] Make example error out-of-the-box (UP023) (astral-sh#19291)
## Summary Part of astral-sh#18972 This PR makes [deprecated-c-element-tree (UP023)](https://docs.astral.sh/ruff/rules/deprecated-c-element-tree/#deprecated-c-element-tree-up023)'s example error out-of-the-box. I have no clue why the `import xml.etree.cElementTree` and `from xml.etree import cElementTree` cases are specifically carved out if they do not have an `as ...`, but the tests explicitly call this out, and that's how it is in `pyupgrade`'s source as well. https://github.com/astral-sh/ruff/blob/b5c5f710fc12b5c512a2e5351684b8ffdf33761f/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP023.py#L23-L31 [Old example](https://play.ruff.rs/632b8ce1-393d-45e5-9504-5444ae71a0d8) ```py from xml.etree import cElementTree ``` [New example](https://play.ruff.rs/fef4d378-8c54-41b2-8778-2d02bcbbd7d3) ```py from xml.etree import cElementTree as ET ``` The "Use instead" section was also updated similarly. ## Test Plan <!-- How was it tested? --> N/A, no functionality/tests affected
1 parent b5c5f71 commit 6660b11

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_c_element_tree.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ use crate::{AlwaysFixableViolation, Edit, Fix};
1414
///
1515
/// ## Example
1616
/// ```python
17-
/// from xml.etree import cElementTree
17+
/// from xml.etree import cElementTree as ET
1818
/// ```
1919
///
2020
/// Use instead:
2121
/// ```python
22-
/// from xml.etree import ElementTree
22+
/// from xml.etree import ElementTree as ET
2323
/// ```
2424
///
2525
/// ## References

0 commit comments

Comments
 (0)