refactor: add I to ruff extend rules#1966
Merged
Merged
Conversation
CodSpeed Performance ReportMerging #1966 will not alter performanceComparing Summary
|
Pull Request Test Coverage Report for Build 17231813731Details
💛 - Coveralls |
There was a problem hiding this comment.
Pull Request Overview
This PR refactors multiple parts of the codebase to both address new ruff lint rules (adding I and SIM) and improve code clarity by streamlining conditionals and import orders. Key changes include:
- Combining nested conditionals into single-line expressions where applicable.
- Reordering and consolidating import statements.
- Replacing try/except blocks with contextlib.suppress for more concise exception handling.
Reviewed Changes
Copilot reviewed 20 out of 22 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tortoise/query_utils.py | Combined nested condition for BackwardFKRelation handling |
| tortoise/models.py | Refactored custom primary key parsing and DB routing logic |
| tortoise/fields/data.py | Reformatted multi-line condition for DateTime/timezone handling |
| tortoise/expressions.py | Improved import order for clarity |
| tortoise/converters.py | Streamlined conditional formatting via a ternary operator |
| tortoise/contrib/test/init.py | Replaced try/except with contextlib.suppress for DB cleanup |
| tortoise/contrib/pylint/init.py | Simplified exception handling using contextlib.suppress |
| tortoise/contrib/postgres/search.py | Simplified ternary operator for Function handling in search criterion |
| tortoise/contrib/mysql/search.py | Updated imports to align with current style conventions |
| tortoise/contrib/mysql/json_functions.py | Consolidated import ordering |
| tortoise/backends/psycopg/client.py | Combined async context managers for connection and cursor |
| tortoise/backends/mysql/client.py | Unified async context management and exception suppression |
| tortoise/backends/base/schema_generator.py | Refactored default field handling with a combined condition |
| tortoise/backends/base/executor.py | Streamlined iteration and conditional checks in field projections |
| tortoise/backends/asyncpg/client.py | Condensed parameter handling for SQL queries |
| tests/test_only.py | Fixed import ordering |
| tests/backends/test_postgres.py | Replaced try/except with contextlib.suppress in test scenarios |
| tests/backends/test_mysql.py | Updated exception suppression to use contextlib.suppress |
| pyproject.toml | Added new ruff extend rules ("I", "SIM") and per-file ignores |
| examples/transactions.py | Streamlined exception suppression using contextlib.suppress |
waketzheng
force-pushed
the
flake8-simplify
branch
from
June 22, 2025 12:29
31110b0 to
a64331b
Compare
henadzit
approved these changes
Aug 26, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Ito ruff extend rules which was missing when migrated isort to ruffMotivation and Context
This is a addition for #1963
How Has This Been Tested?
make ci
Checklist: