Skip to content

Conversation

@waketzheng
Copy link
Contributor

@waketzheng waketzheng commented Jun 13, 2025

Description

  1. Add I to ruff extend rules which was missing when migrated isort to ruff

Motivation and Context

This is a addition for #1963

How Has This Been Tested?

make ci

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added the changelog accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codspeed-hq
Copy link

codspeed-hq bot commented Jun 13, 2025

CodSpeed Performance Report

Merging #1966 will not alter performance

Comparing waketzheng:flake8-simplify (666d74d) with develop (dc8042c)

Summary

✅ 16 untouched benchmarks

@coveralls
Copy link

coveralls commented Jun 13, 2025

Pull Request Test Coverage Report for Build 17231813731

Details

  • 3 of 3 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.003%) to 89.868%

Totals Coverage Status
Change from base Build 17187798592: -0.003%
Covered Lines: 6672
Relevant Lines: 7236

💛 - Coveralls

@waketzheng waketzheng requested review from abondar and henadzit June 16, 2025 08:37
@henadzit henadzit requested a review from Copilot June 19, 2025 12:01
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 waketzheng changed the title refactor: add I and SIM to ruff extend rules refactor: add I to ruff extend rules Jun 22, 2025
@waketzheng waketzheng merged commit f660db0 into tortoise:develop Aug 27, 2025
9 checks passed
@waketzheng waketzheng deleted the flake8-simplify branch August 28, 2025 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants