-
Notifications
You must be signed in to change notification settings - Fork 125
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
chore: fix pandas-stubs issues #2008
Merged
MarcoGorelli
merged 17 commits into
narwhals-dev:main
from
MarcoGorelli:pandas-typing-issues
Feb 17, 2025
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
cbb0669
chore: fix pandas-stubs issues
MarcoGorelli 1a2e5f3
fix
MarcoGorelli 9c486da
fix
MarcoGorelli 1960fc2
fx
MarcoGorelli bd80c9c
Merge remote-tracking branch 'upstream/main' into pandas-typing-issues
MarcoGorelli b372a12
remove from mypy overrides
MarcoGorelli 6b8047a
Merge branch 'main' into pandas-typing-issues
MarcoGorelli 66f7b0d
Merge remote-tracking branch 'upstream/main' into pr/MarcoGorelli/2008
dangotbanned d4d8d39
fix typing tests
dangotbanned 7cf8e73
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 7152492
fix(typing): avoid `TypeVar` in tests
dangotbanned c711332
remove unused ignores
dangotbanned bad8f97
fix(DRAFT): maybe detect `"numpy_nullable"` w/ public api
dangotbanned a4dc352
test: resolve most of the new warnings
dangotbanned 6a78fc9
test: resolve remaining warnings
dangotbanned bb5665c
fix(typing): resolve `polars` warning
dangotbanned 269fdb4
Merge branch 'main' into pandas-typing-issues
dangotbanned File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
from typing import Iterable | ||
from typing import Sequence | ||
from typing import TypeVar | ||
from typing import cast | ||
|
||
import pandas as pd | ||
|
||
|
@@ -511,7 +512,11 @@ def get_dtype_backend(dtype: Any, implementation: Implementation) -> DTypeBacken | |
if hasattr(pd, "ArrowDtype") and isinstance(dtype, pd.ArrowDtype): | ||
return "pyarrow" | ||
with suppress(AttributeError): | ||
if isinstance(dtype, pd.core.dtypes.dtypes.BaseMaskedDtype): | ||
sentinel = object() | ||
if ( | ||
isinstance(dtype, pd.api.extensions.ExtensionDtype) | ||
and getattr(dtype, "base", sentinel) is None | ||
): | ||
Comment on lines
+515
to
+519
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Related to avoiding Available since Pretty sure we don't need |
||
return "numpy_nullable" | ||
return None | ||
|
||
|
@@ -722,8 +727,17 @@ def int_dtype_mapper(dtype: Any) -> str: | |
def convert_str_slice_to_int_slice( | ||
str_slice: slice, columns: pd.Index | ||
) -> tuple[int | None, int | None, int | None]: | ||
start = columns.get_loc(str_slice.start) if str_slice.start is not None else None | ||
stop = columns.get_loc(str_slice.stop) + 1 if str_slice.stop is not None else None | ||
# We can safely cast to int because we know that `columns` doesn't contain duplicates. | ||
start = ( | ||
cast(int, columns.get_loc(str_slice.start)) | ||
if str_slice.start is not None | ||
else None | ||
) | ||
stop = ( | ||
cast(int, columns.get_loc(str_slice.stop)) + 1 | ||
if str_slice.stop is not None | ||
else None | ||
) | ||
step = str_slice.step | ||
return (start, stop, step) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm getting quite a lot of warnings for
pd.core
frompyright
Screenshot
I think I resolved this before in
altair
by finding a more public import path