Skip to content

added typing IntervalClosedType where needed #52894

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 25, 2023

Conversation

gmollard
Copy link
Contributor

@phofl

@mroeschke mroeschke added Interval Interval data type Typing type annotations, mypy/pyright type checking labels Apr 24, 2023
@phofl phofl added this to the 2.1 milestone Apr 24, 2023
@@ -1099,7 +1100,7 @@ class IntervalDtype(PandasExtensionDtype):

_cache_dtypes: dict[str_type, PandasExtensionDtype] = {}

def __new__(cls, subtype=None, closed: str_type | None = None):
def __new__(cls, subtype=None, closed=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add it here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried, but I have an issue with mypy if I do this: it complains about the variable reassignement l.1141:
closed = gd["closed"]

pandas/core/dtypes/dtypes.py:1141: error: Incompatible types in assignment (expression has type "Union[str, Any]", variable has type "Optional[Union[Literal['left', 'right'], Literal['both', 'neither']]]") [assignment]

Do you know if there is a way to fix this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding # type: ignore[assignment] in 1141 would work here. This isn't ideal, but it's better if the function signature is typed more strictly

Copy link
Contributor Author

@gmollard gmollard Apr 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added what you suggested but I have a check that fails, I don't know why..
Do you have an idea of what's the reason?

@phofl
Copy link
Member

phofl commented Apr 25, 2023

this is unrelated, minimum versions is sometimes flaky

@phofl phofl merged commit 4802abe into pandas-dev:main Apr 25, 2023
@phofl
Copy link
Member

phofl commented Apr 25, 2023

thx @gmollard

Rylie-W pushed a commit to Rylie-W/pandas that referenced this pull request May 19, 2023
Daquisu pushed a commit to Daquisu/pandas that referenced this pull request Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Interval Interval data type Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TYP: Make typing consistent for closed argument in Interval associated methods/classes
3 participants