Skip to content

Reduce too-many-statements across piccolo codebase#1397

Open
waniasantos wants to merge 6 commits into
piccolo-orm:masterfrom
grazi-lima:refactor/too-many-statements
Open

Reduce too-many-statements across piccolo codebase#1397
waniasantos wants to merge 6 commits into
piccolo-orm:masterfrom
grazi-lima:refactor/too-many-statements

Conversation

@waniasantos

@waniasantos waniasantos commented Jun 30, 2026

Copy link
Copy Markdown

Summary

Refactors 6 occurrences of Pylint's too-many-statements (R0915) by extracting cohesive blocks of logic into smaller, well-named auxiliary functions/methods. Consistent pattern applied across the codebase: large functions broken down by responsibility (column collection, foreign key resolution, type-specific handlers, query building), with no changes to existing business logic.

Refactored functions/methods

  • Table.__init_subclass__ (table.py)
  • create_table_class_from_db (apps/schema/commands/generate.py)
  • MigrationManager._run_alter_columns (apps/migrations/auto/migration_manager.py)
  • serialise_params (apps/migrations/auto/serialisation.py)
  • Select.default_querystrings (query/methods/select.py)
  • create_pydantic_model (utils/pydantic.py)

Validation

  • Full test suite (pytest) passes after each refactor
  • Pylint R0915 score: 10/10 on all affected functions/methods
  • No changes to the public API

Notes

  • All 6 occurrences also resolved their corresponding too-many-branches (R0912) violations on the same function/method, since the extracted logic contained most of the conditional branching
  • One implementation issue was caught via test suite: during the Table.__init_subclass__ refactor, several TableMeta methods were accidentally moved into the wrong nested class, causing an AttributeError. This was identified by running the full test suite and corrected before committing.

…duce __init_subclass__ statements and branches
…create_table_class_from_db to reduce statements and branches (R0915/R0912)
…dispatch pattern to reduce statements and branches (R0915/R0912)
…ault_querystrings to reduce statements and branches (R0915/R0912)
…reate_pydantic_model to reduce statements and branches (R0915/R0912)
@waniasantos waniasantos marked this pull request as ready for review June 30, 2026 05:47
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.

1 participant