Skip to content
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

Complete signature of value_counts #995

Merged
merged 1 commit into from
Sep 9, 2024

Conversation

refack
Copy link
Contributor

@refack refack commented Sep 8, 2024

For Index, Series, DataFrame

Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

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

Changes needed to use the check(assert_type(...)) pattern in new tests.

tests/test_frame.py Outdated Show resolved Hide resolved
tests/test_indexes.py Outdated Show resolved Hide resolved
tests/test_series.py Outdated Show resolved Hide resolved
For Index, Series, DataFrame
Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

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

Thanks @refack

@Dr-Irv Dr-Irv merged commit 0a5115d into pandas-dev:main Sep 9, 2024
10 checks passed
@refack
Copy link
Contributor Author

refack commented Sep 9, 2024

We're requiring that on any new tests.

I did that, but those are suboptimal for my setup. Assignment to a type hinted variable is analyzed in PyCharm, while annotating with assert_type is transparent since the signature is assert_type(val: T_, typ: Any, /) -> T_
Screenshot 2024-09-09 151809

Both forms err for pyright/mypy.
Screenshot 2024-09-09 152247

and since syntactically the type parameter is not in a type-hint positions, we need to do the "string" trick
Screenshot 2024-09-09 153144

@refack refack deleted the index.count_values branch September 9, 2024 20:36
@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Sep 9, 2024

I did that, but those are suboptimal for my setup. Assignment to a type hinted variable is analyzed in PyCharm, while annotating with assert_type is transparent since the signature is assert_type(val: T_, typ: Any, /) -> T_

That's an issue with the type checker within PyCharm (which we don't support) having a different behavior than mypy and pyright . So with assert_type(), we have to surround the types that are not available at runtime (e.g., Series[int]) in quotes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants