Skip to content

Missing py.typed for type checking? #57

@gishor

Description

@gishor

What happens?

After upgrading from 1.3.2 to 1.4.0, mypy complains whenever we import duckdb.

The error message is of the form:

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

The .pyifiles moved from the duckdb-stubs folder to duckdb itself. This page says:

Package maintainers who wish to support type checking of their code MUST add a marker file named py.typed to their package supporting typing. This marker applies recursively: if a top-level package includes it, all its sub-packages MUST support type checking as well.

And:

For stub-only packages adding a py.typed marker is not needed since the name *-stubs is enough to indicate it is a source of typing information.

So is a py.typed file needed now with the new version?

To Reproduce

$ echo "import duckdb" > test.py

# Success with 1.3.2
$ pip install duckdb==1.3.2 > /dev/null && mypy test.py
Success: no issues found in 1 source file

# Error with 1.4.0
$ pip install duckdb==1.4.0 > /dev/null && mypy test.py
test.py:1: error: Skipping analyzing "duckdb": module is installed, but missing library stubs or py.typed marker  [import-untyped]
test.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file)

# Adding py.typed fixes the issue
$ touch $(dirname $(python -c "import duckdb; print(duckdb.__file__)"))/py.typed
$ pip install duckdb==1.4.0 > /dev/null && mypy test.py
Success: no issues found in 1 source file

OS:

OSX

DuckDB Package Version:

1.3.2 and 1.4.0

Python Version:

3.13.7

Full Name:

Gishor Sivanrupan

Affiliation:

Exaforce

What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have tested with a stable release

Did you include all relevant data sets for reproducing the issue?

Not applicable - the reproduction does not require a data set

Did you include all code required to reproduce the issue?

  • Yes, I have

Did you include all relevant configuration to reproduce the issue?

  • Yes, I have

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions