Skip to content

Comments

fix: remove pandas.concat signature hook#2173

Merged
cosmicBboy merged 1 commit intounionai-oss:mainfrom
kitagry:fix-pandas-concat
Nov 22, 2025
Merged

fix: remove pandas.concat signature hook#2173
cosmicBboy merged 1 commit intounionai-oss:mainfrom
kitagry:fix-pandas-concat

Conversation

@kitagry
Copy link
Contributor

@kitagry kitagry commented Nov 21, 2025

Hi maintainers! Thank you for nice project!

Summary

Fixes #2124 - Remove pandas.concat signature hook that causes mypy to crash

Problem

MyPy 1.17.1+ crashes with AttributeError: 'Instance' object has no attribute 'items' when analyzing code that uses pd.concat(). This occurs because:

  1. pandas-stubs 2.3.2.250827 now returns either Instance or UnionType for concat's first argument
  2. Our pandas_concat_callback hook assumes the argument type is UnionType and tries to access its .items attribute
  3. This assumption is no longer valid with the updated pandas-stubs

Solution

Remove the pandas_concat_callback hook and its associated get_function_signature_hook method entirely because:

  • In update mypy plugin and tests #1007, we removed PANDAS_CONCAT_FALSE_POSITIVES workarounds since pandas-stubs (now officially maintained by pandas-dev) provides correct types
  • The signature manipulation is no longer necessary with modern pandas-stubs
  • This aligns with the project's direction to rely on official pandas type stubs rather than custom workarounds

Changes

  • Remove get_function_signature_hook method from PanderaPlugin
  • Remove pandas_concat_callback method
  • Add return code validation in tests to catch mypy failures

Testing

  • Tested locally with mypy 1.18.2 to verify the fix resolves the crash
  • Note: The project dependencies keep mypy at 1.10.0 because upgrading mypy causes widespread type errors across the codebase that are outside the scope of this fix
  • Existing mypy tests pass without crashes

Signed-off-by: Ryo Kitagawa <kitadrum50@gmail.com>
@codecov
Copy link

codecov bot commented Nov 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.48%. Comparing base (812b2a8) to head (c4a20a7).
⚠️ Report is 387 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2173       +/-   ##
===========================================
- Coverage   94.28%   81.48%   -12.80%     
===========================================
  Files          91      137       +46     
  Lines        7013    10871     +3858     
===========================================
+ Hits         6612     8858     +2246     
- Misses        401     2013     +1612     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cosmicBboy
Copy link
Collaborator

thanks @kitagry ! 🚀

@cosmicBboy cosmicBboy merged commit b48e0e3 into unionai-oss:main Nov 22, 2025
223 of 224 checks passed
@kitagry kitagry deleted the fix-pandas-concat branch November 22, 2025 04:22
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.

MyPy 1.17.1 crashing when using Pandera 0.25.0 and pandas-stubs 2.3.2.250827

2 participants