Skip to content

refactor: extract helpers to reduce pylint complexity - #834

Open
renansuaris wants to merge 2 commits into
redis:mainfrom
renansuaris:refactor/too-many-statements
Open

refactor: extract helpers to reduce pylint complexity#834
renansuaris wants to merge 2 commits into
redis:mainfrom
renansuaris:refactor/too-many-statements

Conversation

@renansuaris

@renansuaris renansuaris commented May 26, 2026

Copy link
Copy Markdown

What does this change do?

Refactors the too-many-statements violations reported by Pylint in large methods across the codebase by extracting parts of the logic into smaller private helpers.

Why is this needed?

The affected methods were handling too many responsibilities in a single block, which made them harder to read, test, and maintain. Splitting the logic into smaller helpers reduces complexity while keeping the external behavior unchanged.

What changed?

  • Internal logic was split into smaller helper functions
  • Main methods remain as orchestrators
  • No intentional behavior changes
  • Migration flow and metrics were preserved

How was it tested?

  • Existing tests continue to pass.

Notes for reviewers

  • The refactor was kept minimal and focused only on the reported cases

Note

Low Risk
Mechanical refactors with no intended behavior change; the only new contract assertion is dry-run monitoring keys, while query and schema logic was moved without API changes.

Overview
Splits oversized methods into private helpers to satisfy Pylint complexity limits while keeping behavior the same.

Datetime hash migration (datetime_migration.py): per-key hash scanning, byte normalization, and datetime field updates move into _collect_hash_keys, _normalize_hash_data, and _process_hash_key; _process_hash_model only batches and delegates.

Data migrator monitoring (migrator.py): pending-migration logging, result dict assembly, and verbose summary printing move to _log_pending_migrations, _build_monitoring_result, and _log_monitoring_summary. Dry-run results still omit success_rate and set dry_run: True—covered by a new test in tests/test_data_migrator.py.

Core model (model.py): RediSearch query value resolution is decomposed by field type (_resolve_text_value, _resolve_numeric_value, _resolve_tag_value, etc.); query execute is split into build-args, run command, and parse results; ModelMeta.__new__ and JSON index schema_for_type recursion are broken into smaller static/class methods with the same orchestration flow.

Reviewed by Cursor Bugbot for commit 3abe023. Bugbot is set up for automated code reviews on this repo. Configure here.

@jit-ci

jit-ci Bot commented May 26, 2026

Copy link
Copy Markdown

Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset.

In case there are security findings, they will be communicated to you as a comment inside the PR.

Hope you’ll enjoy using Jit.

Questions? Comments? Want to learn more? Get in touch with us.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit b80c1a6. Configure here.

Comment thread aredis_om/model/migrations/data/migrator.py
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.

2 participants