Add type hints and py.typed marker (PEP 561) - #112
Merged
Conversation
lfoppiano
force-pushed
the
feature/issue-71-type-hints
branch
from
July 23, 2026 14:36
93d5f84 to
2b538a3
Compare
Annotate the whole codebase (client, main GrobidClient, the TEI2LossyJSON and TEI2Markdown converters, the CLIs and the validator) and ship a py.typed marker so type checkers pick up the inline hints. Each module uses 'from __future__ import annotations' so annotations stay lazy and cannot affect runtime behavior (and remain valid on Python 3.8). Packaging: - add grobid_client/py.typed and expose it via package-data and MANIFEST.in - include the grobid_client.format subpackage in the distribution - add a [tool.mypy] section (ignore missing third-party stubs; relax the BeautifulSoup-heavy converter modules whose dynamic API yields false positives) CI: - install mypy and run 'mypy grobid_client' in the build workflow (on 3.11) mypy runs clean on the package and the existing test-suite still passes. Closes #71
lfoppiano
force-pushed
the
feature/issue-71-type-hints
branch
from
July 23, 2026 15:21
2b538a3 to
1f16f36
Compare
lfoppiano
added a commit
that referenced
this pull request
Aug 11, 2026
The package ships a py.typed marker since #112, which promises inline types to type checkers of anything importing it; the methods added by this branch had none, so process_paths, process_archive and the S3 helpers came back untyped to every user of the client. The signatures now match the ones on master. _open_archive's handle stays Any on purpose: a ZipFile and a TarFile share no interface here, which is exactly why the function returns a "kind" tag for the callers to dispatch on. mypy --ignore-missing-imports is clean on the module, as it is on master.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Annotate the whole codebase (client, main GrobidClient, the TEI2LossyJSON and TEI2Markdown converters, the CLIs and the validator) and ship a py.typed marker so type checkers pick up the inline hints. Each module uses 'from future import annotations' so annotations stay lazy and cannot affect runtime behavior (and remain valid on Python 3.8).
Packaging:
mypy runs clean on the package and the existing test-suite still passes.
Closes #71