fix(types): resolve typecheck warnings#269
Conversation
|
Warning Review limit reached
More reviews will be available in 1 hour. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (14)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR focuses on eliminating ty typecheck warnings across the codebase by tightening MSA-related typing (including deterministic ordering for Protenix), normalizing a Protenix MSA output-dir argument type, and removing now-stale ty: ignore[...] comments that were producing warnings.
Changes:
- Refine MSA typing/ordering: introduce a deterministic key sort helper for mixed
int/strkeys and add coverage for it. - Normalize Protenix MSA search invocation (cast output directory to
str) and clean up related typing. - Remove unnecessary
ty: ignore[...]suppressions across tests and runtime code where types are now accepted or warnings are gone.
Confidence: ~80% (reviewed all provided diff hunks; one typing semantic issue flagged via PR comment).
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/utils/test_msa.py | Adds a regression test for deterministic mixed-key sorting used by Protenix MSA logic. |
| tests/utils/test_framework_utils.py | Removes now-stale ty: ignore suppressions for negative/error-path tests. |
| tests/utils/test_atom_array_utils.py | Removes stale ty: ignore suppressions in error-path tests. |
| tests/conftest.py | Removes type-ignore suppressions for tensor ops/return typing in a fixture. |
| src/sampleworks/utils/msa.py | Introduces MSAData alias + deterministic Protenix key ordering; normalizes Protenix out-dir argument type. |
| src/sampleworks/utils/framework_utils.py | Removes no-longer-needed ty: ignore suppressions around broadcast/tile operations. |
| src/sampleworks/models/rf3/wrapper.py | Removes ty: ignore for a pipeline call now expected to typecheck cleanly. |
| src/sampleworks/models/boltz/wrapper.py | Removes ty: ignore suppressions by relying on updated MSA/GenerativeModelInput typing. |
| src/sampleworks/metrics/rmsd.py | Removes stale ignores around add_global_token_id_annotation usage. |
| src/sampleworks/metrics/lddt.py | Removes stale ignores around add_global_token_id_annotation usage. |
| src/sampleworks/core/samplers/edm.py | Removes a stale ignore for scalar–tensor multiplication. |
| src/sampleworks/core/forward_models/xray/real_space_density_deps/qfit/unitcell.py | Removes unused file-level typecheck suppression directives. |
| src/sampleworks/core/forward_models/xray/real_space_density_deps/qfit/transformer.py | Removes unused file-level ty suppression directive. |
| src/sampleworks/core/forward_models/xray/real_space_density_deps/qfit/sf.py | Removes unused file-level ty suppression directive (keeps ruff ignore). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| MAX_PAIRED_SEQS = 8192 | ||
| MAX_MSA_SEQS = 16384 | ||
| MSAData = Mapping[str, str] | Mapping[int, str] | Mapping[str | int, str] | ||
|
|
There was a problem hiding this comment.
@xraymemory I think I agree with copilot here, and would use dict explicitly. Does that not get rid of the warnings for _compute_msa?
|
Validation update after the latest fix:
|
marcuscollins
left a comment
There was a problem hiding this comment.
Left a few comments but nothing blocking. Approved.
| # AtomArrayStack at runtime | ||
| predicted_atom_array_stack = add_global_token_id_annotation( | ||
| predicted_atom_array_stack # ty: ignore[invalid-argument-type] | ||
| predicted_atom_array_stack = cast( |
There was a problem hiding this comment.
This seems like something we should fix in AtomWorks or push into our own macromolecular-observables package. The AtomWorks problem is that they don't properly annotate the input/output types. Probably we should just put it in our own package and move away from AtomWorks.
There was a problem hiding this comment.
In any event, I dislike cast because of the visual distraction, so we should fix the underlying problem, but for this PR I don't think anything needs to be done except to create an issue.
| MAX_PAIRED_SEQS = 8192 | ||
| MAX_MSA_SEQS = 16384 | ||
| MSAData = Mapping[str, str] | Mapping[int, str] | Mapping[str | int, str] | ||
|
|
There was a problem hiding this comment.
@xraymemory I think I agree with copilot here, and would use dict explicitly. Does that not get rid of the warnings for _compute_msa?
|
|
||
| with pytest.raises(TypeError, match="can only accept AtomArray or AtomArrayStack"): | ||
| select_altloc(invalid_input, "A") # ty: ignore[invalid-argument-type] | ||
| select_altloc(cast(Any, invalid_input), "A") |
There was a problem hiding this comment.
I'm surprised this doesn't still flag it as an invalid argument type. Can you explain?
| # make sure sort order stays the same: | ||
| data_keys = sorted(data.keys()) | ||
| sequences = [data[key] for key in data_keys] | ||
| data_items = sorted(data.items(), key=lambda item: _msa_data_key_sort_key(item[0])) |
There was a problem hiding this comment.
Maybe add a comment what _msa_data_key_sort_key does (and maybe give it a better name?)
| assert base != MSAManager._hash_arguments({"B": "GGGAA", "A": "MKTAY"}, "greedy") | ||
|
|
||
|
|
||
| def test_msa_data_key_sort_preserves_numeric_order_and_handles_mixed_keys(): |
There was a problem hiding this comment.
IMO, this is a perfect unit test in that it explains why the function is needed in the first place.
Summary
Fixes #249
Validation