Skip to content

Add py.typed marker so type checkers see spiceypy's annotations#552

Open
Sammy-Dabbas wants to merge 1 commit into
AndrewAnnex:mainfrom
Sammy-Dabbas:issue-415-py-typed
Open

Add py.typed marker so type checkers see spiceypy's annotations#552
Sammy-Dabbas wants to merge 1 commit into
AndrewAnnex:mainfrom
Sammy-Dabbas:issue-415-py-typed

Conversation

@Sammy-Dabbas

Copy link
Copy Markdown

Fixes #415.

This adds the PEP 561 py.typed marker plus the two packaging lines needed to ship it: the Typing :: Typed classifier and an sdist.include entry, since the existing include globs only match *.py and *.pyx. The wheel side needs no change because scikit-build-core's package auto-detection picks up non-Python files inside src/spiceypy; I confirmed that with a minimal repro pinned to the same scikit-build-core version, and verified the built sdist contains src/spiceypy/py.typed.

On the concern from the 2021 discussion about internal mypy errors: shipping the marker does not expose them to users. mypy does not re-check site-packages internals when following imports, so downstream projects only see the public annotations. I demonstrated the user-facing effect in a fresh venv against the 8.1.2 wheel: before the marker, mypy reports import-untyped and silently ignores two deliberate type errors in user code calling spiceypy; with the marker present, both are caught ([assignment] and [arg-type]). A mypy pass over spiceypy's own internals would be worthwhile as an independent follow-up, but it is not a prerequisite for the marker.

Adds the PEP 561 marker, the Typing :: Typed classifier, and an
sdist.include entry (the existing globs only match *.py/*.pyx). The
wheel picks the marker up automatically via scikit-build-core package
auto-detection.

Fixes AndrewAnnex#415.
@AndrewAnnex

Copy link
Copy Markdown
Owner

@Sammy-Dabbas my apologies but I only just noticed the pull request, thanks for thinking to contribute! I will review this more in depth over the coming week. My only initial thought though is that point on rechecking the current annotations first before including this change because otherwise users will experience not a lot of benefit if mypy is indicating errors due to incorrect type annotations. This in the past was going to be a very tedious task but is pretty tractable with improved linter tools and ai tools available. But once I have some time to sit and think on it I will see if I want to stick to that requirement or not.

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.

Add py.typed for mypy compatibility

2 participants