mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
[flake8-use-pathlib
] Make example error out-of-the-box (PTH210
) (#19189)
<!-- Thank you for contributing to Ruff/ty! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? (Please prefix with `[ty]` for ty pull requests.) - Does this pull request include references to any relevant issues? --> ## Summary <!-- What's the purpose of the change? What does it do, and why? --> Part of #18972 This PR makes [invalid-pathlib-with-suffix (PTH210)](https://docs.astral.sh/ruff/rules/invalid-pathlib-with-suffix/#invalid-pathlib-with-suffix-pth210)'s example error out-of-the-box. [Old example](https://play.ruff.rs/d45720cc-fd08-4443-820f-b3bc9756ac59) ```py path.with_suffix("py") ``` [New example](https://play.ruff.rs/4103669e-19c5-464a-a3fb-6e7d190ce5fd) ```py from pathlib import Path path = Path() path.with_suffix("py") ``` The "Use instead" section was also modified similarly. ## Test Plan <!-- How was it tested? --> N/A, no functionality/tests affected
This commit is contained in:
parent
e23780c2e1
commit
de5264fe13
1 changed files with 8 additions and 0 deletions
|
@ -19,12 +19,20 @@ use ruff_text_size::Ranged;
|
|||
/// ## Example
|
||||
///
|
||||
/// ```python
|
||||
/// from pathlib import Path
|
||||
///
|
||||
/// path = Path()
|
||||
///
|
||||
/// path.with_suffix("py")
|
||||
/// ```
|
||||
///
|
||||
/// Use instead:
|
||||
///
|
||||
/// ```python
|
||||
/// from pathlib import Path
|
||||
///
|
||||
/// path = Path()
|
||||
///
|
||||
/// path.with_suffix(".py")
|
||||
/// ```
|
||||
///
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue