Skip to content

CLN: simplify logic in json date parsing regarding warnings - #66760

Merged
jorisvandenbossche merged 2 commits into
pandas-dev:mainfrom
jorisvandenbossche:json-depr-warning-simplify
Aug 17, 2026
Merged

CLN: simplify logic in json date parsing regarding warnings#66760
jorisvandenbossche merged 2 commits into
pandas-dev:mainfrom
jorisvandenbossche:json-depr-warning-simplify

Conversation

@jorisvandenbossche

Copy link
Copy Markdown
Member

I was looking at this logic introduced in #64645 in the json date parsing code (was changing something there in context of another PR), and didn't directly understand what was going on. Tried to simplify this a bit (while the tests are still passing).

One consequence might be that we are also silencing any other warning (besides the specific warning about quarterly strings) for the attempts are not returned, but that seems a good thing

@jorisvandenbossche jorisvandenbossche added IO JSON read_json, to_json, json_normalize Clean labels Aug 14, 2026
Comment thread pandas/io/json/_json.py
Comment on lines -1740 to -1745
if (
not kept
and issubclass(warning.category, Pandas4Warning)
and _QUARTER_DEPR_MSG in str(warning.message)
):
continue

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we only call this helper function when we have the data that will actually be returned, I don't think we need this filter or the kept keyword

@jbrockmendel

Copy link
Copy Markdown
Member

mypy complaint, otherwise lgtm

@jorisvandenbossche
jorisvandenbossche merged commit 8dfcb75 into pandas-dev:main Aug 17, 2026
52 checks passed
@jorisvandenbossche
jorisvandenbossche deleted the json-depr-warning-simplify branch August 17, 2026 13:08
Sharl0tteIsTaken added a commit to Sharl0tteIsTaken/pandas that referenced this pull request Aug 18, 2026
…-comparison

* upstream/main: (63 commits)
  BUG: to_json dropping the seconds of a sub-minute UTC offset (pandas-dev#66818)
  CI: fix working directory for the web interactive_terminal task (pandas-dev#66810)
  DEPS: Bump pyarrow minimum version to 16.0 (pandas-dev#66358)
  BUG: bar plot raises AttributeError when the DatetimeIndex freq attribute is unset (pandas-dev#66771)
  BLD: Build Python 3.15 wheels (pandas-dev#66808)
  PERF: enable parallel read_csv by default on Windows (pandas-dev#66751)
  [pre-commit.ci] pre-commit autoupdate (pandas-dev#66609)
  TST: avoid resetting RNG in MultiIndex duplicate test (pandas-dev#66806)
  CLN: simplify logic in json date parsing regarding warnings (pandas-dev#66760)
  CI: fix UBSan suppressions silently going inert with meson 1.12.0 (pandas-dev#66805)
  CI: Close PRs with linked issues that aren't assigned (pandas-dev#66803)
  CI: Update pixi.lock (pandas-dev#66799)
  TST: Add test for writing UUIDs to parquet with pyarrow pandas-dev#61602 (pandas-dev#65647)
  BUG: to_json wrapped unsigned numpy scalars above int64 max (GH#66142) (pandas-dev#66796)
  BUG: remaining ujson_dumps segfaults from unchecked C-API returns (GH#66356) (pandas-dev#66797)
  CI: Update pixi to 0.76.2 + relock (pandas-dev#66793)
  BUG: pandas-dev#66356 - Fix 4 segfaults from ujson_dumps values that are abnormal (pandas-dev#66357)
  PERF: single-pass string conversion in read_csv's pyarrow fast path (pandas-dev#66756)
  BUG: secondary_y hid the primary y-axis over collection-drawn data (pandas-dev#66789)
  BUG: read_csv(sep=None) raised TypeError instead of falling back to the python engine (GH#66639) (pandas-dev#66790)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Clean IO JSON read_json, to_json, json_normalize

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants