mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 22:55:08 +00:00
Add pyupgrade UP041
to replace TimeoutError
aliases (#8476)
## Summary Add UP041 to replace `TimeoutError` aliases: * Python 3.10+: `socket.timeout` * Python 3.11+: `asyncio.TimeoutError` Re: * https://github.com/asottile/pyupgrade#timeouterror-aliases * https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError * https://docs.python.org/3/library/socket.html#socket.timeout Based on `os_error_alias.rs`. ## Test Plan <!-- How was it tested? --> By running: ``` cargo clippy --workspace --all-targets --all-features -- -D warnings # Rust linting RUFF_UPDATE_SCHEMA=1 cargo test # Rust testing and updating ruff.schema.json pre-commit run --all-files --show-diff-on-failure # Rust and Python formatting, Markdown and Python linting, etc. cargo insta review ``` And also running with different `--target-version` values: ```sh cargo run -p ruff_cli -- check crates/ruff_linter/resources/test/fixtures/pyupgrade/UP041.py --no-cache --select UP041 --target-version py37 --diff cargo run -p ruff_cli -- check crates/ruff_linter/resources/test/fixtures/pyupgrade/UP041.py --no-cache --select UP041 --target-version py310 --diff cargo run -p ruff_cli -- check crates/ruff_linter/resources/test/fixtures/pyupgrade/UP041.py --no-cache --select UP041 --target-version py311 --diff ```
This commit is contained in:
parent
4982694b54
commit
65effc6666
9 changed files with 386 additions and 0 deletions
|
@ -500,6 +500,7 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> {
|
|||
(Pyupgrade, "038") => (RuleGroup::Stable, rules::pyupgrade::rules::NonPEP604Isinstance),
|
||||
(Pyupgrade, "039") => (RuleGroup::Stable, rules::pyupgrade::rules::UnnecessaryClassParentheses),
|
||||
(Pyupgrade, "040") => (RuleGroup::Stable, rules::pyupgrade::rules::NonPEP695TypeAlias),
|
||||
(Pyupgrade, "041") => (RuleGroup::Preview, rules::pyupgrade::rules::TimeoutErrorAlias),
|
||||
|
||||
// pydocstyle
|
||||
(Pydocstyle, "100") => (RuleGroup::Stable, rules::pydocstyle::rules::UndocumentedPublicModule),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue