Skip to content

Repo-wide mypy cannot include connector tests because every connector exposes a top-level tests package #66

Description

@goanpeca

Summary

A repo-wide non-core mypy run fails before it can type-check anything because
each connector package has a tests/__init__.py, so mypy maps them all to the
same top-level module name tests. CI avoids the problem by type-checking only
connector source packages (libs/connectors/$conn/genblaze_*/), which means
connector tests and typed fixtures are not covered by any type gate.

This is distinct from issue #18 (core mypy config is bypassed) and issue #21
(root pytest collects only core tests). This one is specifically about package
layout blocking a whole-repo typecheck that includes test code.

Affected files

  • libs/connectors/*/tests/__init__.py (13 connector packages all define a top-level tests package)
  • .github/workflows/ci.yml:76-88 (connector typecheck loop checks only genblaze_* source directories)
  • Makefile:65-66 (make typecheck checks only core)
  • pyproject.toml:20-21 (root config points pytest only at core, so there is no root-level test layout pressure)

Evidence

Running mypy over the non-core tree from the requested conda env:

/Users/gpenacastellanos/miniforge3/envs/genblaze/bin/python -m mypy \
  libs/connectors cli libs/meta --hide-error-context --no-error-summary

fails immediately:

libs/connectors/elevenlabs/tests/__init__.py: error: Duplicate module named "tests" (also at "libs/connectors/decart/tests/__init__.py")
libs/connectors/elevenlabs/tests/__init__.py: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#mapping-file-paths-to-modules for more info

The duplicate packages are present across all connector test roots:

libs/connectors/decart/tests/__init__.py
libs/connectors/elevenlabs/tests/__init__.py
libs/connectors/gmicloud/tests/__init__.py
libs/connectors/google/tests/__init__.py
libs/connectors/langsmith/tests/__init__.py
libs/connectors/lmnt/tests/__init__.py
libs/connectors/luma/tests/__init__.py
libs/connectors/nvidia/tests/__init__.py
libs/connectors/openai/tests/__init__.py
libs/connectors/replicate/tests/__init__.py
libs/connectors/runway/tests/__init__.py
libs/connectors/s3/tests/__init__.py
libs/connectors/stability-audio/tests/__init__.py

Why it matters

Test code is part of the maintenance surface: fixtures, fake provider classes,
SDK mocks, and replay/test helpers exercise public APIs and often catch typing
drift earlier than production code. The current layout makes it awkward to add a
single "type-check everything including tests" command. Contributors either
need to remember package-local invocations or accept that connector tests are
outside the type signal.

This also blocks future cleanup work from issues #18, #19, #27, #32, and #34 if
the desired end state is a coherent monorepo typing gate rather than many
ad-hoc commands.

Suggested fix

Choose one explicit layout/policy:

  • Remove connector tests/__init__.py files if they are not needed, so mypy
    treats test files as standalone modules.
  • Or run mypy with --explicit-package-bases / package-specific config so each
    connector root is mapped intentionally.
  • Or rename tests into package-qualified modules (for example
    genblaze_openai_tests) if importable test packages are required.

Then add a documented target such as make typecheck-all or expand the existing
target to cover connector, CLI, meta, and test code without duplicate-module
errors.

Acceptance criteria

  • A documented mypy command can type-check connector source and connector tests
    in one pass, or via an automated package loop, without duplicate tests
    module errors.
  • CI either runs that command or clearly documents why tests are intentionally
    excluded from typing.
  • Package-local pytest behavior remains unchanged.

Metadata

Metadata

Assignees

No one assigned

    Type

    Fields

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions