Skip to content

Commit

Permalink
Fix mypy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
avaucher committed Jul 11, 2024
1 parent 5cfb952 commit 8191d61
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/rxn/chemutils/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from .exceptions import InvalidInchi, InvalidMdl, InvalidSmiles, SanitizationError

RDLogger.logger().setLevel(RDLogger.CRITICAL)
RDLogger.logger().setLevel(RDLogger.CRITICAL) # type: ignore[no-untyped-call]


def smiles_to_mol(
Expand Down Expand Up @@ -57,7 +57,7 @@ def smiles_to_mol(
# function, either with no sanitization, or with radical finding.
if not sanitize:
if find_radicals:
sanitizations = [Chem.SANITIZE_FINDRADICALS]
sanitizations: List[SanitizeFlags | int] = [Chem.SANITIZE_FINDRADICALS]
else:
sanitizations = [Chem.SANITIZE_NONE]

Expand All @@ -84,7 +84,7 @@ def inchi_to_mol(inchi: str, sanitize: bool = True, removeHs: bool = True) -> Mo
Returns:
Mol instance.
"""
mol = MolFromInchi(inchi, sanitize=sanitize, removeHs=removeHs)
mol: Mol = MolFromInchi(inchi, sanitize=sanitize, removeHs=removeHs) # type: ignore[no-untyped-call]
if not inchi or mol is None:
raise InvalidInchi(inchi)

Expand All @@ -97,7 +97,7 @@ def mol_to_smiles(mol: Mol, canonical: bool = True, isomericSmiles: bool = True)
Mainly a wrapper around MolToSmiles.
"""
return MolToSmiles(mol, canonical=canonical, isomericSmiles=isomericSmiles) # type: ignore
return MolToSmiles(mol, canonical=canonical, isomericSmiles=isomericSmiles)


def mdl_to_mol(mdl: str, sanitize: bool = True) -> Mol:
Expand Down Expand Up @@ -130,7 +130,7 @@ def mol_to_mdl(mol: Mol) -> str:
Mainly a wrapper around MolToMolBlock.
"""
return MolToMolBlock(mol) # type: ignore
return MolToMolBlock(mol)


def sanitize_mol(
Expand Down Expand Up @@ -239,7 +239,7 @@ def canonicalize_smiles(smiles: str, check_valence: bool = True) -> str:

# Sanitization as a separate step, to enable exclusion of valence check
try:
excluded_sanitizations = []
excluded_sanitizations: List[SanitizeFlags | int] = []
if not check_valence:
excluded_sanitizations.append(Chem.SANITIZE_PROPERTIES)
sanitize_mol(mol, exclude_sanitizations=excluded_sanitizations)
Expand Down
4 changes: 2 additions & 2 deletions src/rxn/chemutils/miscellaneous.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def atom_type_counter(smiles: str) -> typing.Counter[str]:
"""

mol: Mol = AddHs(smiles_to_mol(smiles, sanitize=False))
atoms: List[Atom] = mol.GetAtoms()
atoms: List[Atom] = mol.GetAtoms() # type: ignore[call-arg,no-untyped-call]
return Counter(atom.GetSymbol() for atom in atoms)


Expand Down Expand Up @@ -327,7 +327,7 @@ def mol_has_atom_mapping(mol: Mol) -> bool:
mol: RDKit Mol.
"""
atom: Atom
for atom in mol.GetAtoms():
for atom in mol.GetAtoms(): # type: ignore[call-arg,no-untyped-call]
if atom.GetAtomMapNum() != 0:
return True
return False
Expand Down

0 comments on commit 8191d61

Please sign in to comment.