You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When adding check on inferred type for each level in MultiIndex for columns, error message pops up in CI (Typing validation with mypy):
pandas/io/parquet.py:59: error: "Index" has no attribute "levels"; maybe "nlevels"? [attr-defined]
I understand that single-level Indexes do not have the "levels" attribute while MultiIndexes have the "levels" attribute. It seems that mypy static type checking may have inferred "df.columns" as Index type by default, hence flagging the error when using "df.columns.levels" in the code change.
Would it make sense to add a "levels" attribute to "Index" for consistency with MultiIndex, or are there any possible workarounds for this mypy error?
The text was updated successfully, but these errors were encountered:
Rather than adding an attribute to silence this error I think you could use a more explicit check to convince mypy it's a MultiIndex (commented in the PR as well)
Observed in PR #36305
When adding check on inferred type for each level in MultiIndex for columns, error message pops up in CI (Typing validation with mypy):
pandas/io/parquet.py:59: error: "Index" has no attribute "levels"; maybe "nlevels"? [attr-defined]
I understand that single-level Indexes do not have the "levels" attribute while MultiIndexes have the "levels" attribute. It seems that mypy static type checking may have inferred "df.columns" as Index type by default, hence flagging the error when using "df.columns.levels" in the code change.
Would it make sense to add a "levels" attribute to "Index" for consistency with MultiIndex, or are there any possible workarounds for this mypy error?
The text was updated successfully, but these errors were encountered: