Skip to content

Commit 690ca20

Browse files
lyskovlyskov-ai
andcommitted
Clear rfd3na input_parsing from the mypy ratchet
Now unblocked by the 0078 port of _check_has_backbone_connections_to_ nonstandard_residues. Mirrors the rfd3 fix: add the four missing imports (create_o_atoms/create_cb_atoms, fetch_mask_from_idx, and the ported _check_has_backbone helper -- all NameErrors); fix create_motif_residue's error message to use the token's own chain_id/res_id (was undefined src_chain/src_resid); narrow accumulate_components' components to List[str] (the int was spurious) and unindexed_breaks to List[bool|None]; rewrite a list-comp-for-side-effects as a set loop; data: dict|None; and a components->component typo. rfd3na is cluster-coupled; the NameError fixes make reachable paths work but are unverified in CI. mypy-only otherwise. Co-authored-by: lyskov-ai <277346777+lyskov-ai@users.noreply.github.com>
1 parent 7809032 commit 690ca20

2 files changed

Lines changed: 13 additions & 12 deletions

File tree

models/rfd3na/src/rfd3na/inference/input_parsing.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
backbone_atoms_RNA,
3535
)
3636
from rfd3na.inference.legacy_input_parsing import (
37+
_check_has_backbone_connections_to_nonstandard_residues,
3738
create_atom_array_from_design_specification_legacy,
3839
reorder_atoms_per_residue,
3940
)
@@ -52,6 +53,8 @@
5253
from rfd3na.transforms.util_transforms import assign_types_
5354
from rfd3na.utils.inference import (
5455
_restore_bonds_for_nonstandard_residues,
56+
create_cb_atoms,
57+
create_o_atoms,
5558
extract_ligand_array,
5659
inference_load_,
5760
set_com,
@@ -61,6 +64,7 @@
6164

6265
from foundry.common import exists
6366
from foundry.utils.components import (
67+
fetch_mask_from_idx,
6468
get_design_pattern_with_constraints,
6569
get_motif_components_and_breaks,
6670
)
@@ -925,7 +929,7 @@ def create_atom_array_from_design_specification(
925929

926930

927931
@contextmanager
928-
def validator_context(validator_name: str, data: dict = None):
932+
def validator_context(validator_name: str, data: dict | None = None):
929933
"""Context manager for validator execution with logging."""
930934
logger.debug(f"Starting validator: {validator_name}")
931935
try:
@@ -1003,7 +1007,8 @@ def create_motif_residue(
10031007
diffuse_oxygen = False
10041008
if n_atoms < 3:
10051009
raise ValueError(
1006-
f"Not enough data for {src_chain}{src_resid} in input atom array."
1010+
f"Not enough data for {token.chain_id[0]}{token.res_id[0]} "
1011+
"in input atom array."
10071012
)
10081013
if n_atoms == 3:
10091014
# Handle cases with N, CA, C only;
@@ -1037,7 +1042,7 @@ def create_motif_residue(
10371042

10381043

10391044
def accumulate_components(
1040-
components_to_accumulate: List[Union[str, int]],
1045+
components_to_accumulate: List[str],
10411046
*,
10421047
# Tokens from input
10431048
indexed_tokens: Dict[str, AtomArray],
@@ -1046,7 +1051,7 @@ def accumulate_components(
10461051
atom_array_accum=[],
10471052
start_chain: str = "A",
10481053
start_resid: int = 1,
1049-
unindexed_breaks: Optional[List[bool]] = [],
1054+
unindexed_breaks: Optional[List[bool | None]] = [],
10501055
src_atom_array: Optional[AtomArray] = None,
10511056
strip_sidechains_by_default: bool = False,
10521057
**kwargs,
@@ -1060,12 +1065,9 @@ def accumulate_components(
10601065
x, y
10611066
)
10621067
all_tokens = indexed_tokens | unindexed_tokens
1063-
all_annots = []
1064-
[
1065-
all_annots.extend(list(tok.get_annotation_categories()))
1066-
for tok in all_tokens.values()
1067-
]
1068-
all_annots = set(all_annots)
1068+
all_annots: set = set()
1069+
for tok in all_tokens.values():
1070+
all_annots.update(tok.get_annotation_categories())
10691071
atom_array_accum = [] if atom_array_accum is None else atom_array_accum
10701072
unindexed_breaks = (
10711073
[None] * len(components_to_accumulate)
@@ -1138,7 +1140,7 @@ def accumulate_components(
11381140
n = int(component[:-1])
11391141
else:
11401142
polymer_type = "P"
1141-
n = int(components)
1143+
n = int(component)
11421144

11431145
# ... Skip if none or unindexed
11441146
if n == 0 or unindexed_components_started:

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ check_untyped_defs = false
250250
# of rfd3, so several of these carry the same defects rfd3 fixed (see .ai/roadmap.md findings).
251251
[[tool.mypy.overrides]]
252252
module = [
253-
"rfd3na.inference.input_parsing",
254253
"rfd3na.trainer.fabric_trainer",
255254
]
256255
ignore_errors = true

0 commit comments

Comments
 (0)