-
Notifications
You must be signed in to change notification settings - Fork 46
test(e2e): fix mypy Optional narrowing in test_session_runtime #1046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -537,6 +537,7 @@ def check_worker_service_stopped() -> None: | |
| interval=10, | ||
| ) | ||
| def wait_worker_started() -> None: | ||
| assert worker.worker_id is not None # narrow Optional inside the closure for mypy | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This narrowing assert now lives inside a closure decorated with Note also that line 531 already does A cleaner fix that satisfies mypy without putting a non-retryable precondition inside the retry loop is to bind a local before the closure: worker_id = worker.worker_id
assert worker_id is not None
@backoff.on_exception(backoff.constant, Exception, max_time=120, interval=10)
def wait_worker_started() -> None:
assert is_worker_started(
deadline_client=deadline_client,
farm_id=deadline_resources.farm.id,
fleet_id=deadline_resources.fleet.id,
worker_id=worker_id,
)A local variable stays narrowed inside the closure, so the assert is checked once, up front, and the duplication on line 531 goes away. |
||
| assert is_worker_started( | ||
| deadline_client=deadline_client, | ||
| farm_id=deadline_resources.farm.id, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pinning this gate to a single interpreter means the e2e type check only ever runs one of the two mypy tracks the repo supports.
requirements-e2e.txtsplits on interpreter version:so CI will only exercise mypy 2.3 under 3.11, while a contributor on 3.9 gets mypy 1.19 locally. Separately,
test/e2e/mypy.inisets nopython_version, so mypy infers 3.11 from the running interpreter — version-conditional typing errors under the project minimum (requires-python = ">=3.9") will not be caught here.Two options depending on intent: either add
python_version = 3.9totest/e2e/mypy.iniso the check is pinned to the floor regardless of which interpreter CI happens to use, or give this job the samepython-versionmatrix asUnitTest/IntegrationTestsabove so both mypy tracks are covered. The former is cheaper and probably sufficient; the ruff half ofe2e:lintis version-independent either way.