Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mypy now part of pre-commit (including code changes for it) #474

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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