Skip to content

Add type hints for pymatgen.io.ase module - #2991

Merged
janosh merged 5 commits into
materialsproject:masterfrom
Andrew-S-Rosen:types
May 16, 2023
Merged

janosh merged 5 commits into
materialsproject:masterfrom
Andrew-S-Rosen:types

Conversation

@Andrew-S-Rosen

Copy link
Copy Markdown
Member

Pretty self-explanatory. I added type hints to pymatgen.io.ase.

@Andrew-S-Rosen

Copy link
Copy Markdown
Member Author

Welp, sorry @janosh. I thought this would be a trivial add. But I'm not sure how to make the mypy overlord happy with this...

Comment thread pymatgen/io/ase.py
from pymatgen.core.structure import Molecule, Structure

try:
from ase import Atoms

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this line has to stay here?

@janosh

janosh commented May 16, 2023

Copy link
Copy Markdown
Member

mypy can be a pain. The problem you ran into is that untyped functions are not type-checked. As soon as you add types to a function, it can surface errors that were already lurking in the code.

@janosh

janosh commented May 16, 2023 •

Copy link
Copy Markdown
Member

Oh and I think here you meant

- cls: Structure = None
+ cls: type[Structure] = None

@janosh
janosh enabled auto-merge (squash) May 16, 2023 13:54
shorten ase import
@janosh
janosh merged commit 0b76613 into materialsproject:master May 16, 2023
@Andrew-S-Rosen

Copy link
Copy Markdown
Member Author

Thanks!!

@Andrew-S-Rosen
Andrew-S-Rosen deleted the types branch May 16, 2023 14:22
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.

2 participants