Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pyupgrade UP041 to replace TimeoutError aliases #8476

Merged
merged 2 commits into from Nov 3, 2023

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
Copy link

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
16 checks passed
@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.

None yet

2 participants