Skip to content

Conversation

gishor
Copy link

@gishor gishor commented Sep 16, 2025

https://typing.python.org/en/latest/spec/distributing.html#packaging-type-information

Package maintainers who wish to support type checking of their code
MUST add a marker file named py.typed to their package supporting typing.

Fixes #57

https://typing.python.org/en/latest/spec/distributing.html#packaging-type-information

> Package maintainers who wish to support type checking of their code
MUST add a marker file named py.typed to their package supporting
typing.

Fixes duckdb#57
@evertlammerts
Copy link
Collaborator

evertlammerts commented Sep 16, 2025

FMI: did you test that this works? I'm a little surprised that the __init__.pyi stub isn't picked up and from the docs it isn't clear to me that py.typed will ensure that it does get picked up... doesn't it just signal that the package itself supports type hints?

We could also just move the stub back into its own folder for now, if that's what worked before.

@gishor
Copy link
Author

gishor commented Sep 16, 2025

Yes, I did test it. I ran the same commands as in #57, but I did a uv build and pip install duckdb-python/dist/duckdb-1.4.0.dev213.tar.gz. I tried it from both main and add-py-typed branches.

test.py:

import duckdb
from duckdb.typing import *

main returns:

test.py:1: error: Skipping analyzing "duckdb": module is installed, but missing library stubs or py.typed marker  [import-untyped]
test.py:2: error: Skipping analyzing "duckdb.typing": module is installed, but missing library stubs or py.typed marker  [import-untyped]
test.py:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 2 errors in 1 file (checked 1 source file)

add-py-typed returns:

Success: no issues found in 1 source file

Now I'm not fully sure about the point of py.typed. However it is also mentioned in the mypy docs linked in the error message above and here: https://mypy.readthedocs.io/en/stable/installed_packages.html#creating-pep-561-compatible-packages:

If you would like to publish a library package to a package repository yourself (e.g. on PyPI) for either internal or external use in type checking, packages that supply type information via type comments or annotations in the code should put a py.typed file in their package directory.

This is why I thought it makes sense to add this empty file. I guess a separate folder with only stubs should also work.

@evertlammerts
Copy link
Collaborator

I'm going to make some fixes related to the stub today as part of #62 #57 and #47 . Closing this in favor of that work.

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.

Missing py.typed for type checking?
2 participants