Skip to content

Commit

Permalink
TYP: Annotation updates
Browse files Browse the repository at this point in the history
  • Loading branch information
BvB93 committed Dec 1, 2021
1 parent 23a3466 commit 8dd0a61
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions CAT/data_handling/anchor_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class _UnparsedAnchorDictBase(TypedDict):
class _UnparsedAnchorDict(_UnparsedAnchorDictBase, total=False):
remove: "None | SupportsIndex | Iterable[SupportsIndex]"
angle_offset: "None | SupportsFloat | SupportsIndex | bytes | str"
dihedral: "None | SupportsFloat | SupportsIndex | bytes | str"


class _AnchorDict(TypedDict):
Expand All @@ -31,6 +32,7 @@ class _AnchorDict(TypedDict):
remove: "None | Tuple[int, ...]"
kind: KindEnum
angle_offset: "None | float"
dihedral: "None | float"


def _parse_group_idx(item: "SupportsIndex | Iterable[SupportsIndex]") -> Tuple[int, ...]:
Expand All @@ -40,7 +42,7 @@ def _parse_group_idx(item: "SupportsIndex | Iterable[SupportsIndex]") -> Tuple[i
except TypeError:
pass

ret = tuple(operator.index(i) for i in item)
ret = tuple(operator.index(i) for i in item) # type: ignore[union-attr]
n = len(ret) - len(set(ret))
if n:
raise ValueError(f"Found {n} duplicate elements")
Expand Down Expand Up @@ -124,7 +126,9 @@ def parse_anchors(
ret.append(p)
elif isinstance(p, Mol):
mol = p
remove = None if not split else (list(mol.GetAtoms())[-1].GetIdx(),)
remove: "None | Tuple[int, ...]" = (
None if not split else (list(mol.GetAtoms())[-1].GetIdx(),)
)
ret.append(AnchorTup(mol=mol, remove=remove))
elif isinstance(p, str):
group = p
Expand Down

0 comments on commit 8dd0a61

Please sign in to comment.