Skip to content

Split execute so it no longer needs noqa: C901 - #3082

Merged
janiversen merged 1 commit into
pymodbus-dev:devfrom
sankalpsthakur:refactor/execute-complexity
Nov 4, 2026
Merged

janiversen merged 1 commit into
pymodbus-dev:devfrom
sankalpsthakur:refactor/execute-complexity

Conversation

@sankalpsthakur

Copy link
Copy Markdown
Contributor

As suggested in #3076, this makes the # noqa: C901 on TransactionManager.execute() unnecessary.

  • The reconnect check moves to _connect_if_needed().
  • The handling of a request that got no response after its retries moves to _no_response(). sync_execute() uses it too, so the two methods share that code instead of mirroring it.

Behaviour is unchanged. With ruff check --select C901 --ignore-noqa, execute() goes from 13 to 9 and sync_execute() from 9 to 7.

Validation

  • pytest test/transaction: 54 passed on Python 3.10 and 3.14 (macOS), with 100% line and branch coverage of pymodbus/transaction and test/transaction.
  • pytest test/client: 241 passed. The 3 test_client_tls_connect cases fail the same way on unmodified dev here (local TLS setup).
  • ruff check, ruff format --check, codespell, zuban check and pylint (10.00/10) on the touched file are clean.

AI disclosure: written with an AI coding agent and tested as described above.

The reconnect check moves to _connect_if_needed, and the handling of a request that got no response after its retries moves to _no_response, which sync_execute now uses too.
@janiversen
janiversen merged commit 0ccfdb4 into pymodbus-dev:dev Nov 4, 2026
30 of 32 checks passed
@janiversen

Copy link
Copy Markdown
Collaborator

Thanks, nice split.

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