pymatgen
pymatgen copied to clipboard
The current `py.typed` setup does not seem ideal
Problem
I am using mypy on a package with Pymatgen as a dependency and am getting back the following even though there is a py.typed marker in the base pymatgen directory. Any insights?
schemas/_aliases/emmet.py:11: error: Skipping analyzing "pymatgen.core.composition": module is installed, but missing library stubs or py.typed marker [import]
schemas/_aliases/emmet.py:12: error: Skipping analyzing "pymatgen.core.lattice": module is installed, but missing library stubs or py.typed marker [import]
schemas/_aliases/emmet.py:13: error: Skipping analyzing "pymatgen.core.periodic_table": module is installed, but missing library stubs or py.typed marker [import]
schemas/_aliases/emmet.py:14: error: Skipping analyzing "pymatgen.core.structure": module is installed, but missing library stubs or py.typed marker [import]
schemas/_aliases/emmet.py:15: error: Skipping analyzing "pymatgen.entries.computed_entries": module is installed, but missing library stubs or py.typed marker [import]
schemas/_aliases/emmet.py:16: error: Skipping analyzing "pymatgen.io.vasp.inputs": module is installed, but missing library stubs or py.typed marker [import]
Proposed Solution
Confirm py.typed marker carries over to the full package.
Alternatives
No response
Looks like it's not being shipped despite being included (incorrectly?) as package_data in setup.py
https://github.com/materialsproject/pymatgen/blob/cfd47add8958af795dabcfe1661cf8890ad56415/setup.py#L105
Maybe it wouldn't work with a single py.typed even if shipped successfully since we're using namespace packages?
For namespace packages (see PEP 420), the py.typed file should be in the submodules of the namespace, to avoid conflicts and for clarity.
Very good points that I don't know the answers to!
Potentially relevant: setuptools v69.0.0 release
Include type information (py.typed, *.pyi) by default (https://github.com/pypa/setuptools/issues/3136) -- by @Danie-1, EXPERIMENTAL. (https://github.com/pypa/setuptools/issues/3136)
@janosh: Is it implying that if you're using setuptools, you don't need a py.typed at all? That'd be nice because it's so ugly lol
I think https://github.com/pypa/setuptools/issues/3136 just added a new convenience option include_typing_files = True which we would add in setup.py to make sure we package py.typed. We still need that file it just avoids user error in trying to include that file.
Ah, I see. That makes sense.