Skip to content

chore: add from __future__ import annotations to every module so signatures and help() print types as written #635

Open

Description

@murray-ds

14 of the package's 55 modules start with from __future__ import annotations. The other 41 don't, so
inspect.signature and help() print their annotations as resolved paths:

CohortAnalysis   (df: pandas.core.frame.DataFrame | ibis.expr.types.relations.Table, aggregation_column: str, ...)
NLRSegmentation  (df: 'pd.DataFrame | ibis.Table', period_col: 'str', ...)

CohortAnalysis is in a module without the import; NLRSegmentation is in one with it and prints the types as the
source writes them.

Change

  • Add from __future__ import annotations to every module.
  • Make ruff enforce it (rule I002) with required-imports = ["from __future__ import annotations"] under
    [tool.ruff.lint.isort].

Notes

  • No module reads annotations at runtime (get_type_hints, __annotations__, pydantic), so nothing depends on them
    being evaluated.
  • Each annotation gains quotes ('str'), so the output only gets shorter where it names pandas, ibis or matplotlib
    types. This is a consistency and readability change, not a size change.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions