Fix pandas-stubs where() call-overload error in null normalization#290
Open
bgaidioz wants to merge 1 commit into
Open
Fix pandas-stubs where() call-overload error in null normalization#290bgaidioz wants to merge 1 commit into
bgaidioz wants to merge 1 commit into
Conversation
The where(..., None) pattern in _normalize_pandas_dataframe_nulls and _normalize_pandas_series_nulls is supported at runtime but rejected by pandas-stubs 2.3.3.260113, which no longer lists None in the `other` overload for DataFrame.where / Series.where. This triggers [call-overload] plus a cascading [no-any-return] error and breaks `uv run mypy .` on PR #271's branch. Suppress both errors inline with a short comment explaining the pandas-stubs gap. The PR #278 attempt traded one stricter-stubs error (replace's mapping type) for the same kind of error on where, so this keeps the existing helper structure and just lands the type ignore. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
# type: ignore[call-overload,no-any-return]to the twowhere(value.notna(), None)calls in_normalize_pandas_dataframe_nulls/_normalize_pandas_series_nulls.Noneas theotherarg but it is supported at runtime.Why
PR #278 (commit bccf95a on this branch) tried to fix the
pandas-stubsmypy regression by swappingreplace({pd.NaT: None})forastype(object).where(value.notna(), None). Butpandas-stubs2.3.3.260113 also rejectsNoneas theotherargument ofDataFrame.where/Series.where, so the lint step still fails on the same lines with[call-overload]plus a cascading[no-any-return].This is a well-known gap in pandas-stubs — the standard workaround is an inline
# type: ignore. The fix keeps the existing helper structure introduced in #278 (plus its NaT regression tests) and just silences the overload error.Testing
uv run ruff check .✅uv run black --check --diff .✅uv run mypy .✅ (Success: no issues found in 171 source files)env -u OP_SERVICE_ACCOUNT_TOKEN uv run pytest tests/sdk/validator/ -k "null or nat or nan or normalize"✅ (NaT regression tests still pass)🤖 Generated with Claude Code