Skip to content

chore(typing): decide ty policy + fix diagnostics for examples/ #1980

@jxnl

Description

@jxnl

examples/ is currently excluded from ty checks; running ty on it reports many diagnostics.

Repro:

  • uv sync --all-extras
  • uv run ty check examples (currently: Found 138 diagnostics)

Top buckets observed:

  • Missing optional deps used only in examples (langsmith, streamlit, nltk, spacy, loguru, erdantic, etc.).
  • Examples importing modules that aren’t packaged/importable in that context (e.g. local models, intra-example imports).
  • Intentional “wrong type” example calls that need cast(...) or # type: ignore[...] to keep examples runnable while still type-checkable.

Goal

  • Decide a policy for examples:
    • Either make uv run ty check examples pass with light annotations/guards, or
    • Keep excluded and add a separate optional CI job for “typed examples” subset.

Possible approach

  • Wrap optional imports in try/except ImportError (or if TYPE_CHECKING:) so type checking doesn’t require installing every demo dependency.
  • For “demo-only” type violations, add targeted # type: ignore[rule] with justification.
  • Consider splitting examples that require heavy deps into a separate folder excluded by default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    dependenciesPull requests that update a dependency filedocumentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions