-
-
Notifications
You must be signed in to change notification settings - Fork 157
Open
Labels
DataFrameDataFrame data structureDataFrame data structureIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselvespyright bug
Description
Describe the bug
After an assignment and a raise in a loop, DataFrame.columns becomes Never by pyright. See the minimal example below.
It is likely a pyright bug, but I can't make an example that is independent of pandas and pandas-stubs.
To Reproduce
Provide a minimal runnable pandas example that is not properly checked by the stubs.
from typing_extensions import reveal_type
import pandas as pd
df = pd.DataFrame()
df.columns = [str(c).upper() for c in df.columns]
reveal_type(df.columns) # Index[str], fine
for _ in ():
if "1" in df.columns:
raise
reveal_type(df.columns) # NeverIndicate which type checker you are using
pyright. mypy does not have this problem.
Show the error message received from that type checker while checking your example
ttest.py
ttest.py:8:13 - information: Type of "df.columns" is "Index[str]"
ttest.py:14:13 - information: Type of "df.columns" is "Never"
0 errors, 0 warnings, 2 informations
Please complete the following information
- OS: Windows
- OS Version: 11
- python version: 3.10.11
- version of type checker:
- version of installed
pandas-stubs:main, b4c3b56
Metadata
Metadata
Assignees
Labels
DataFrameDataFrame data structureDataFrame data structureIndexingRelated to indexing on series/frames, not to indexes themselvesRelated to indexing on series/frames, not to indexes themselvespyright bug