Skip to content

fix(types): resolve typecheck warnings#269

Open
xraymemory wants to merge 2 commits into
mainfrom
michaelanzuoni/issue-249-typecheck-warnings
Open

fix(types): resolve typecheck warnings#269
xraymemory wants to merge 2 commits into
mainfrom
michaelanzuoni/issue-249-typecheck-warnings

Conversation

@xraymemory

Copy link
Copy Markdown
Collaborator

Summary

  • tighten MSA typing around string/integer keys and keep deterministic Protenix ordering
  • normalize Protenix MSA output directory argument type
  • remove stale ty/type ignore comments that now produce warnings

Fixes #249

Validation

  • uvx ty check
  • uvx ruff check src/sampleworks/core/forward_models/xray/real_space_density_deps/qfit/sf.py src/sampleworks/core/forward_models/xray/real_space_density_deps/qfit/transformer.py src/sampleworks/core/forward_models/xray/real_space_density_deps/qfit/unitcell.py src/sampleworks/core/samplers/edm.py src/sampleworks/metrics/lddt.py src/sampleworks/metrics/rmsd.py src/sampleworks/models/boltz/wrapper.py src/sampleworks/models/rf3/wrapper.py src/sampleworks/utils/framework_utils.py src/sampleworks/utils/msa.py tests/conftest.py tests/utils/test_atom_array_utils.py tests/utils/test_framework_utils.py tests/utils/test_msa.py
  • PYTHONPATH=src uvx --with pytest --with loguru --with requests --with tqdm pytest --noconftest tests/utils/test_msa.py -q

Copilot AI review requested due to automatic review settings June 22, 2026 16:51
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@xraymemory, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f5f96f7e-1d66-43be-a827-c2009c404454

📥 Commits

Reviewing files that changed from the base of the PR and between 72f5118 and 4033e23.

📒 Files selected for processing (14)
  • src/sampleworks/core/forward_models/xray/real_space_density_deps/qfit/sf.py
  • src/sampleworks/core/forward_models/xray/real_space_density_deps/qfit/transformer.py
  • src/sampleworks/core/forward_models/xray/real_space_density_deps/qfit/unitcell.py
  • src/sampleworks/core/samplers/edm.py
  • src/sampleworks/metrics/lddt.py
  • src/sampleworks/metrics/rmsd.py
  • src/sampleworks/models/boltz/wrapper.py
  • src/sampleworks/models/rf3/wrapper.py
  • src/sampleworks/utils/framework_utils.py
  • src/sampleworks/utils/msa.py
  • tests/conftest.py
  • tests/utils/test_atom_array_utils.py
  • tests/utils/test_framework_utils.py
  • tests/utils/test_msa.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch michaelanzuoni/issue-249-typecheck-warnings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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/str keys 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.

Comment on lines 20 to +23
MAX_PAIRED_SEQS = 8192
MAX_MSA_SEQS = 16384
MSAData = Mapping[str, str] | Mapping[int, str] | Mapping[str | int, str]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@xraymemory I think I agree with copilot here, and would use dict explicitly. Does that not get rid of the warnings for _compute_msa?

@manzuoni-astera

manzuoni-astera commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Validation update after the latest fix:

  • Local validation passed:
    • uvx ty check
    • ruff on the touched files
    • PYTHONPATH=src uvx --with pytest --with loguru --with requests --with tqdm pytest --noconftest tests/utils/test_msa.py -q → 8 passed
  • GitHub CI run 27974194229 is green for lint, tests, and typecheck across boltz-dev/protenix-dev/rf3-dev.
  • Remaining non-code status: GPU Tests run 27974191560 is still WAITING on its boltz-dev/protenix-dev/rf3-dev jobs, with no failure logs available yet.

@marcuscollins marcuscollins requested a review from DorisMai June 23, 2026 20:13

@marcuscollins marcuscollins left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Comment on lines 20 to +23
MAX_PAIRED_SEQS = 8192
MAX_MSA_SEQS = 16384
MSAData = Mapping[str, str] | Mapping[int, str] | Mapping[str | int, str]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@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")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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]))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe add a comment what _msa_data_key_sort_key does (and maybe give it a better name?)

Comment thread tests/utils/test_msa.py
assert base != MSAManager._hash_arguments({"B": "GGGAA", "A": "MKTAY"}, "greedy")


def test_msa_data_key_sort_preserves_numeric_order_and_handles_mixed_keys():

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

IMO, this is a perfect unit test in that it explains why the function is needed in the first place.

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.

Typecheck warning

4 participants