Skip to content

Commit

Permalink
Merge pull request #474 from xchem/m2ms-1240-achristie
Browse files Browse the repository at this point in the history
mypy now part of pre-commit (including code changes for it)
  • Loading branch information
alanbchristie authored Dec 15, 2023
2 parents 02aee14 + 700b22a commit ba27fa4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 29 deletions.
20 changes: 10 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ repos:
# --------------------------------

# MyPy
#- repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.7.1
# hooks:
# - id: mypy
# additional_dependencies:
# - types-PyYAML
# - types-pymysql
# - types-pytz
# - types-python-dateutil
# - types-requests
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.7.1
hooks:
- id: mypy
additional_dependencies:
- types-PyYAML
- types-pymysql
- types-pytz
- types-python-dateutil
- types-requests

# Pylint
- repo: https://github.com/pycqa/pylint
Expand Down
35 changes: 16 additions & 19 deletions viewer/target_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@
METADATA_FILE = "meta_aligner.yaml"


# type hint for Djanog model instance
ModelInstance = TypeVar("ModelInstance", bound=Model)


class UploadState(str, Enum):
"""Target loader progress state.
Expand Down Expand Up @@ -91,7 +87,7 @@ class MetadataObject:
dicts with key that are needed.
"""

instance: ModelInstance
instance: Model
index_data: dict = field(default_factory=dict)


Expand Down Expand Up @@ -875,7 +871,7 @@ def process_canon_site(
@create_objects(depth=1)
def process_canon_site_conf(
self,
canon_sites: dict[str, ModelInstance],
canon_sites: dict[str, Model],
item_data: tuple[str, dict] | None = None,
**kwargs,
) -> ProcessedObject | None:
Expand Down Expand Up @@ -930,7 +926,7 @@ def process_canon_site_conf(
def process_xtalform_site(
self,
xtalforms: dict[int | str, MetadataObject],
canon_sites: dict[str, ModelInstance],
canon_sites: dict[str, Model],
item_data: tuple[str, dict] | None = None,
**kwargs,
) -> ProcessedObject | None:
Expand Down Expand Up @@ -989,7 +985,7 @@ def process_site_observation(
self,
experiments: dict[int | str, MetadataObject],
compounds: dict[int | str, MetadataObject],
xtalform_sites: dict[str, ModelInstance],
xtalform_sites: dict[str, Model],
canon_site_confs: dict[int | str, MetadataObject],
item_data: tuple[str, str, str, int | str, int | str, dict] | None = None,
# chain: str,
Expand Down Expand Up @@ -1068,17 +1064,18 @@ def process_site_observation(
)

mol_data = None
try:
with open(
self.raw_data.joinpath(ligand_mol),
"r",
encoding="utf-8",
) as f:
mol_data = f.read()
except TypeError:
# this site observation doesn't have a ligand. perfectly
# legitimate case
pass
if ligand_mol:
try:
with open(
self.raw_data.joinpath(ligand_mol),
"r",
encoding="utf-8",
) as f:
mol_data = f.read()
except TypeError:
# this site observation doesn't have a ligand. perfectly
# legitimate case
pass

smiles = extract(key="ligand_smiles")

Expand Down

0 comments on commit ba27fa4

Please sign in to comment.