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

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

Merged
merged 5 commits into from
May 16, 2023
Merged

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

merged 5 commits into from
May 16, 2023

Conversation

Andrew-S-Rosen
Copy link
Member

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

@Andrew-S-Rosen
Copy link
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...

@@ -13,13 +13,12 @@
from pymatgen.core.structure import Molecule, Structure

try:
from ase import Atoms
Copy link
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
Copy link
Member

janosh commented May 16, 2023

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
Copy link
Member

janosh commented May 16, 2023

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
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