Skip to content

[1.4.1 regression] In the downstream projects, running mypy . --install-types attempts to install types-tensorflow, even though tensorflow is unused and not installed #194

Closed

Description

@alessio-locatelli

What happens?

Now

In a downstream project that does not need tensorflow:

mypy . --install-types
Installing missing stub packages:
/var/home/sam/.cache/pypoetry/virtualenvs/[masked]-project-CHA1Tb9V-py3.13/bin/python -m pip install types-PySocks types-grpcio types-grpcio-status types-protobuf types-psycopg2 types-tensorflow types-xlrd

Feature

Update the code to do not trigger the types-tensorflow installation.

When the problem was introduced

This happens since duckdb==1.4.1 and maybe related to f5d4e42 or other new commits that went into the 1.4.1 release.

To Reproduce

Irrelevant.

OS:

Fedora

DuckDB Package Version:

1.4.1

Python Version:

3.13.7

Full Name:

Alessio Locatelly

Affiliation:

None

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?

Yes

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

Activity

  1. evertlammerts commented on Dec 6, 2025

    @evertlammerts
    Member

    The stubs include tensorflow types for the tf functions: def tf(*, connection: DuckDBPyConnection | None = None) -> dict[str, tensorflow.Tensor]. My guess is that this is why mypy tries to install them?

  2. evertlammerts commented on Feb 17, 2026

    @evertlammerts
    Member

    Fixed in #323. Removed the tensorflow and torch imports from the TYPE_CHECKING block. The return types of .tf() and .torch() now use Any instead of tensorflow.Tensor / pytorch.Tensor. This means downstream projects won't get prompted to install types-tensorflow when running mypy --install-types. The trade-off is that callers lose the Tensor return type. My guess is that these are niche methods. Let's see whether I'm right about this.

  3. added a commit that references this issue on Feb 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions