Skip to content

Add pyupgrade UP041 to replace TimeoutError aliases#8476

Merged
charliermarsh merged 2 commits intoastral-sh:mainfrom
hugovk:pyupgrade-timeouterror
Nov 3, 2023
Merged

Add pyupgrade UP041 to replace TimeoutError aliases#8476
charliermarsh merged 2 commits intoastral-sh:mainfrom
hugovk:pyupgrade-timeouterror

Conversation

@hugovk
Copy link
Contributor

@hugovk hugovk commented Nov 3, 2023

Summary

Add UP041 to replace TimeoutError aliases:

  • Python 3.10+: socket.timeout
  • Python 3.11+: asyncio.TimeoutError

Re:

Based on os_error_alias.rs.

Test Plan

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:

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

@charliermarsh charliermarsh added the rule Implementing or modifying a lint rule label Nov 3, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2023

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@charliermarsh
Copy link
Member

Thanks @hugovk, this looks great.

@charliermarsh
Copy link
Member

I moved the rule to preview as per our versioning policy -- it will be upgraded to stable in our next minor release.

@charliermarsh charliermarsh enabled auto-merge (squash) November 3, 2023 17:20
@charliermarsh charliermarsh merged commit 65effc6 into astral-sh:main Nov 3, 2023
@hugovk hugovk deleted the pyupgrade-timeouterror branch November 3, 2023 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants