Skip to content

Set up type checking with mypy#49

Open
eerovaher wants to merge 3 commits intoastropy:mainfrom
eerovaher:type-checking
Open

Set up type checking with mypy#49
eerovaher wants to merge 3 commits intoastropy:mainfrom
eerovaher:type-checking

Conversation

@eerovaher
Copy link
Member

The first commit enables type checking with mypy. The astropy_iers_data/_version.py file that setuptools_scm generates when astropy_iers_data is installed is annotated and mypy can infer all the types everywhere else, so there is no need write any annotations. Adding basic mypy configuration is sufficient to enable type checking.

The second commit adds the py.typed marker file which declares support for type checking in downstream packages. Without this marker file type checking code that depends on astropy_iers_data causes typing errors:

error: Skipping analyzing "astropy_iers_data": module is installed, but missing library stubs or py.typed marker  [import-untyped]

The third commit adds a tox environment and a CI job for type checking so that any typing errors in the future could be caught here before they cause problems downstream.

`setuptools_scm` ensures `astropy_iers_data/_version.py` is annotated
and mypy can infer all the types everywhere else, so adding mypy
configuration is all that is needed to enable type checking.
PEP 561 – Distributing and Packaging Type Information requires packages
that support type checking in downstream packages to declare that with a
marker file named `py.typed`.
@eerovaher eerovaher requested a review from astrofrog December 15, 2025 17:29
@eerovaher eerovaher added the enhancement New feature or request label Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant