Repository navigation
test: satisfy ruff 0.17 in test_ibkr.py (unblocks #169) - #170
Merged
Merged
Conversation
Ruff 0.17 flags four pre-existing issues in the IBKR connection test: unsorted imports (I001), a bare Exception (TRY002), and a silent try/except/pass (S110 + BLE001). The lock-file-maintenance bump to ruff 0.17.4 turns these into a failing lint gate. Sort the imports, raise a dedicated IBKRConnectionError, and catch the OSError the client actually raises while keeping the caught error as the cause.
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.
Problem
renovate/lock-file-maintenance(PR #169) is green everywhere except Lint and type check. The lockfile refresh moves ruff from 0.11.13 to 0.17.4, and the newer ruff flags four pre-existing issues intests/test_ibkr.py:Nothing in the test was broken by the dependency bump — the lint gate simply sees more than it used to.
Approach
Smallest change that clears all four without changing the test's intent (retry up to three times, then fail loudly):
IBKRConnectionErrorinstead of raising bareException(TRY002);OSError— whatconnectAsyncactually raises:ConnectionRefusedError,ConnectionErrorandTimeoutErrorare allOSErrorsubclasses — and re-raise with the caught error as the cause, so neither the blind catch nor the silentpassremains (S110, BLE001).Evidence
Run locally in a clean clone, on the PR's own ruff version:
Also re-checked against master's locked ruff 0.11.13 — still passes.
Behaviour check (no gateway on localhost:8888 here): the test retries three times, catches each
OSError, and fails withIBKRConnectionErrorchained to the connection error — same behaviour as before, now with a usable message.Unrelated and pre-existing: importing
ib_insyncon Python 3.15 raisesRuntimeError: There is no current event loopinsideeventkitat collection time; on 3.12 the module imports fine. Not touched here.Merging this should let PR #169 rebase and go green.