Skip to content

Private types leak into Eval public signature, causing reportUnknownMemberType under strict pyright #239

@willfrey

Description

@willfrey

Problem

braintrust.Eval's overloaded signature references several private types:

  • _EvalCaseDict
  • _EvalCaseDictNoOutput
  • _ExperimentDatasetEvent

Under pyright's strict mode, any symbol prefixed with _ from another module is treated as private/unexported. Because these appear in the data parameter's union, pyright flags the entire Eval signature as "partially unknown":

Type of "Eval" is partially unknown

This forces downstream consumers in strict mode to either suppress reportUnknownMemberType or route through Any, even though the types are perfectly well-defined — they're just underscore-prefixed.

Reproduction

# pyproject.toml
[tool.pyright]
typeCheckingMode = "strict"
import braintrust

braintrust.Eval(...)  # reportUnknownMemberType: Type of "Eval" is partially unknown

pyright 1.1.408, braintrust 0.0.173.

Suggested fix

Either:

  1. Rename the types to drop the underscore prefix (EvalCaseDict, EvalCaseDictNoOutput, ExperimentDatasetEvent) and export them, or
  2. Restructure the overloads so private types don't appear in the public signature (e.g. widen to a structural protocol or TypedDict base)

Metadata

Metadata

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions