Skip to content

Conversation

@Anthchirp
Copy link
Contributor

This enables a mypy precommit for dlstbx, and fixes a bunch of outstanding type issues.

The following remain:

src/dlstbx/mimas/core.py:48: error: Item "None" of "Optional[MimasDetectorClass]" has no attribute "name"
src/dlstbx/mimas/core.py:72: error: Item "None" of "Optional[MimasDetectorClass]" has no attribute "name"
src/dlstbx/mimas/core.py:496: error: Item "None" of "Optional[Literal[MimasDetectorClass.EIGER]]" has no attribute "name"
src/dlstbx/wrapper/alphafold.py:15: error: Invalid type comment or annotation
src/dlstbx/wrapper/alphafold.py:15: note: Suggestion: use pydantic.constr[...] instead of pydantic.constr(...)
src/dlstbx/wrapper/alphafold.py:16: error: Invalid type comment or annotation
src/dlstbx/wrapper/alphafold.py:16: note: Suggestion: use pydantic.conint[...] instead of pydantic.conint(...)
src/dlstbx/wrapper/alphafold.py:19: error: Invalid type comment or annotation
src/dlstbx/wrapper/alphafold.py:19: note: Suggestion: use pydantic.confloat[...] instead of pydantic.confloat(...)
src/dlstbx/services/trigger.py:781: error: Incompatible types in assignment (expression has type "Tuple[PDBFileOrCode, ...]", variable has type "List[PDBFileOrCode]")
src/dlstbx/services/trigger.py:813: error: Item "None" of "Optional[Path]" has no attribute "with_name"
src/dlstbx/services/trigger.py:814: error: Item "None" of "Optional[Path]" has no attribute "stem"
src/dlstbx/services/trigger.py:814: error: Item "None" of "Optional[Path]" has no attribute "suffix"
src/dlstbx/services/trigger.py:817: error: Argument 1 to "fspath" has incompatible type "Optional[Path]"; expected "PathLike[str]"
src/dlstbx/services/trigger.py:827: error: Argument 1 to "fspath" has incompatible type "Optional[Path]"; expected "PathLike[str]"
src/dlstbx/services/trigger.py:1148: error: Unsupported left operand type for + ("None")
src/dlstbx/services/trigger.py:1148: note: Left operand is of type "Optional[str]"
Found 13 errors in 3 files (checked 221 source files)

Some of them are stuff I don't want to look into (pydantic), others (mimas/trigger.py) are real type inconsistencies where stuff is defined as Optional but then code assumes it will never see None.

Comment on lines +28 to +36
centre_x: Optional[int] = None
centre_y: Optional[int] = None
centre_x_box: Optional[int] = None
centre_y_box: Optional[int] = None
status: str = "fail"
message: str = "fail"
best_image: int = None
reflections_in_best_image: int = None
best_region: List[Tuple[int, int]] = None
best_image: Optional[int] = None
reflections_in_best_image: Optional[int] = None
best_region: Optional[List[Tuple[int, int]]] = None
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While adding Optional is the minimally invasive and technically correct solution it may not be appropriate. One for RG to decide?

@rjgildea
Copy link

rjgildea commented Dec 15, 2021

I've fixed the alphafold wrapper/trigger service issues. Mimas issues should be addressed in #131.

@Anthchirp Anthchirp merged commit e5bb75d into master Jan 7, 2022
@Anthchirp Anthchirp deleted the mypy branch January 7, 2022 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants