Skip to content

Fix pandas-stubs where() call-overload error in null normalization#290

Open
bgaidioz wants to merge 1 commit into
dependabot/uv/pandas-stubs-2.3.3.260113from
fix/pr271-pandas-stubs-where-overload
Open

Fix pandas-stubs where() call-overload error in null normalization#290
bgaidioz wants to merge 1 commit into
dependabot/uv/pandas-stubs-2.3.3.260113from
fix/pr271-pandas-stubs-where-overload

Conversation

@bgaidioz
Copy link
Copy Markdown
Contributor

Summary

  • Add # type: ignore[call-overload,no-any-return] to the two where(value.notna(), None) calls in _normalize_pandas_dataframe_nulls / _normalize_pandas_series_nulls.
  • Inline comment notes that pandas-stubs rejects None as the other arg but it is supported at runtime.

Why

PR #278 (commit bccf95a on this branch) tried to fix the pandas-stubs mypy regression by swapping replace({pd.NaT: None}) for astype(object).where(value.notna(), None). But pandas-stubs 2.3.3.260113 also rejects None as the other argument of DataFrame.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.

⚠️ Note: PR #278 was merged without ever running CI because the workflow filter branches: '*' doesn't match branch names with slashes (so a PR whose base is a dependabot branch never triggers). This PR has the same limitation. Recommended to verify by re-running CI on PR #271 after merge.

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

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>
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.

1 participant