Skip to content

typing.Union and astral-sh/ty #1298

@hunterhogan

Description

@hunterhogan

In my searches of pandas-stubs, this is the only instance of typing.Union.

# following Union is here to make it ty compliant https://github.com/astral-sh/ty/issues/591
AggFuncTypeBase: TypeAlias = Union[Callable, str, np.ufunc] # noqa: UP007

There are some commented-out uses.

Commented-out

# Not used in stubs
# AggObjType = Union[
# "Series",
# "DataFrame",
# "GroupBy",
# "SeriesGroupBy",
# "DataFrameGroupBy",
# "BaseWindow",
# "Resampler",
# ]

# ColspaceType = Mapping[Hashable, Union[str, int]] not used in stubs

# Manager = Union["BlockManager", "SingleBlockManager"] not used in stubs

# PositionalIndexer2D = Union[PositionalIndexer, PositionalIndexerTuple] Not used in stubs

# MatplotlibColor = Union[str, Sequence[float]] # not used in stubs

# OffsetCalendar = Union[np.busdaycalendar, "AbstractHolidayCalendar"] not used in stubs or pandas

# def concat(
# objs: Union[
# Iterable[Union[Series, DataFrame]], Mapping[HashableT, Union[Series, DataFrame]]
# ],
# axis: Literal[0, "index"] = ...,
# join: str = ...,
# ignore_index: bool = ...,
# keys=...,
# levels=...,
# names=...,
# verify_integrity: bool = ...,
# sort: bool = ...,
# copy: bool = ...,
# ) -> Union[DataFrame, Series]: ...
# @overload
# def concat(
# objs: Union[
# Iterable[Union[Series, DataFrame]], Mapping[HashableT, Union[Series, DataFrame]]
# ],
# axis: Axis = ...,
# join: str = ...,
# ignore_index: bool = ...,
# keys=...,
# levels=...,
# names=...,
# verify_integrity: bool = ...,
# sort: bool = ...,
# copy: bool = ...,
# ) -> Union[DataFrame, Series]: ...

"ty is in preview"

Warning

ty is in preview and is not ready for production use.

We're working hard to make ty stable and feature-complete, but until then, expect to encounter bugs,
missing features, and fatal errors.

https://github.com/astral-sh/ty/blob/e663c524c2f20874b31ec971b91f1e58b7b68d88/README.md?plain=1#L9C1-L14C38

Perhaps change how ty is applied to pandas-stubs instead of changing how pandas-stubs works

It's a lot easier to parse predictable, standardized code, you know?

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