Skip to content

Index(DatetimeIndex) erroneously gives Index[Timestamp] #1440

@cmp0xff

Description

@cmp0xff

On 01d597f, the stubs give Index[Timestamp] when providing a DatetimeIndex as data. The result should be DatetimeIndex.

import pandas as pd
from tests import check
from typing import assert_type

data = check(
    assert_type(pd.date_range("2022-01-01", "2022-01-31", freq="D"), pd.DatetimeIndex),
    pd.DatetimeIndex,  # fine
)
check(
    assert_type(pd.Index(data, name="date"), "pd.Index[pd.Timestamp]"), pd.DatetimeIndex  # static typing is wrong
)

This affects test_index_relops.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ConstructorsSeries/DataFrame/Index/pd.array ConstructorsIndexRelated to the Index class or subclasses

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions