python / python/typeshed

geopandas: index type should be Any

Open
#15,111 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stubs: false positive
Dominant language
Python
Stars
5.1k
Forks
2.1k
Avg merge
1d 19h
Merged PRs (30d)
82

Description

My repo currently satisfies pandas-stubs type hints. However, when I add types-geopandas, I see hundreds of new issues:

error: "Index[Any]" has no attribute "overlaps" [attr-defined]
error: "Index[Any]" has no attribute "left" [attr-defined]
error: "Index[Any]" has no attribute "right" [attr-defined]

I'm using pd.IntervalIndex, which has these attributes. However, pandas currently has no way of typing DataFrame indices (https://github.com/pandas-dev/pandas/issues/36708), so there is no way of knowing which kind of index is returned.

I think it would be more correct to use typing.Any here since it is unknown and dynamic.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No specific file or test is named. Start by locating the types-geopandas annotations for DataFrame indices and compare them with pandas' current inability to type index kinds; done means the reported IntervalIndex attribute errors are no longer produced when both stub packages are used.

Written by the indexing model from the issue text.

Assessment

Tech stack
pandas, python
Domain
developer-experience
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.