Skip to content

fix: surface invalid encounter timezone errors - #202

Merged
shivamlalakiya merged 1 commit into
PhilanthroPy-Project:mainfrom
Utkarsh3725:fix-encounter-recency-timezone-error
Sep 9, 2026
Merged

fix: surface invalid encounter timezone errors#202
shivamlalakiya merged 1 commit into
PhilanthroPy-Project:mainfrom
Utkarsh3725:fix-encounter-recency-timezone-error

Conversation

@Utkarsh3725

Copy link
Copy Markdown
Contributor

What & why

Removes the unreachable tz_localize fallback in EncounterRecencyTransformer._parse_dates.

When timezone is set, pd.to_datetime(..., utc=True) already returns timezone-aware parsed dates, so tz_convert() is the correct path. The old broad except Exception fallback only made invalid
timezone errors worse by replacing the useful timezone error with a misleading "Already tz-aware" error.

Closes #201.

Checklist

  • make ci passes locally (lint -> collection -> tests -> coverage >= 92%)
  • New/changed public API has docstrings and is exported in the subpackage __init__.py
  • Tests added or updated
  • CHANGELOG.md updated under [Unreleased]
  • Added yourself to CONTRIBUTORS.md

Testing

  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 .venv/bin/python -m pytest tests/test_encounter_timezone.py tests/test_preprocessing.py -q
    • Result: 68 passed
  • .venv/bin/python -m flake8 philanthropy/preprocessing/_encounter_recency.py

I could not run the coverage version locally because pytest coverage hit a local NumPy import-loader issue in this environment before collecting tests. The focused behavior tests pass.

@shivamlalakiya
shivamlalakiya merged commit fafd5e2 into PhilanthroPy-Project:main Sep 9, 2026
15 checks passed
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.

cleanup: EncounterRecencyTransformer._parse_dates has a tz_localize fallback that utc=True appears to make unreachable

2 participants