Newtype of Pandas dataframe #1303
-
from typing import NewType
import pandas as pd
NewTypeDf = NewType("NewTypeDf", pd.DataFrame)
def test() -> NewTypeDf:
return NewTypeDf(
pd.DataFrame({})
) Pyright report: error: Illegal type annotation: variable not allowed unless it is a type alias (reportGeneralTypeIssues) NewTypeDf = NewType("NewTypeDf", pd.DataFrame) to NewTypeDf = NewType("NewTypeDf", str) , there is no error reported. |
Beta Was this translation helpful? Give feedback.
Answered by
hauntsaninja
Dec 3, 2022
Replies: 1 comment 1 reply
-
Do you have pandas-stubs installed? If not, try installing them and see if it fixes. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
falan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you have pandas-stubs installed? If not, try installing them and see if it fixes.