Skip to content

Add type hints and py.typed marker (PEP 561) - #112

Merged
lfoppiano merged 1 commit into
masterfrom
feature/issue-71-type-hints
Aug 11, 2026
Merged

Add type hints and py.typed marker (PEP 561)#112
lfoppiano merged 1 commit into
masterfrom
feature/issue-71-type-hints

Conversation

@lfoppiano

Copy link
Copy Markdown
Member

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)

mypy runs clean on the package and the existing test-suite still passes.

Closes #71

@lfoppiano
lfoppiano force-pushed the feature/issue-71-type-hints branch from 93d5f84 to 2b538a3 Compare July 23, 2026 14:36
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
lfoppiano force-pushed the feature/issue-71-type-hints branch from 2b538a3 to 1f16f36 Compare July 23, 2026 15:21
@lfoppiano
lfoppiano merged commit a9792d8 into master Aug 11, 2026
7 checks passed
@lfoppiano
lfoppiano deleted the feature/issue-71-type-hints branch August 11, 2026 07:51
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.
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.

Request: adding type hints

1 participant