Skip to content

Vendor deprecate_kwarg to fix pandas 3.0 ImportError (#1005)#1013

Open
Jaypatel1511 wants to merge 1 commit into
pydata:mainfrom
Jaypatel1511:fix/972-famafrench-date-parser-deprecated
Open

Vendor deprecate_kwarg to fix pandas 3.0 ImportError (#1005)#1013
Jaypatel1511 wants to merge 1 commit into
pydata:mainfrom
Jaypatel1511:fix/972-famafrench-date-parser-deprecated

Conversation

@Jaypatel1511

Copy link
Copy Markdown

Summary

Fixes #1005pandas-datareader imported deprecate_kwarg from pandas.util._decorators, a private internal API that is being removed in pandas 3.0. This causes an ImportError on pandas >= 3.0, breaking every import of the library.

Root cause

# pandas_datareader/data.py
from pandas.util._decorators import deprecate_kwarg  # private API, removed in pandas 3.0

Fix

Vendor the deprecate_kwarg implementation directly into pandas_datareader.compat (matching the behaviour of the pandas original), and update data.py to import from there:

# pandas_datareader/data.py
from pandas_datareader.compat import deprecate_kwarg  # no private pandas dependency

The vendored implementation in compat/__init__.py is a faithful port of the pandas original, supporting:

  • Simple old → new kwarg rename with FutureWarning
  • mapping dict or callable for value translation
  • TypeError when both old and new kwargs are passed simultaneously
  • new_arg_name=None for pure deprecation warnings

Test plan

  • 8 new unit tests in tests/test_deprecate_kwarg.py covering all decorator behaviours
  • One AST-based test asserting data.py no longer references pandas.util._decorators
  • All 8 tests pass on Python 3.9 with pandas 2.x

…ecorators (pydata#1005)

pandas-datareader imported deprecate_kwarg from pandas.util._decorators,
a private internal API being removed in pandas 3.0. This caused an
ImportError on pandas >= 3.0.

Fix: vendor the implementation directly in pandas_datareader.compat and
update data.py to import from there instead.
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.

Breakage coming in pandas 3.0

1 participant