Skip to content

[Repo Assist] improve: replace generic Exception with specific exception types in remaining modules#1543

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
repo-assist/improve-specific-exceptions-20260526-8b235af0b7a94f1f
Draft

[Repo Assist] improve: replace generic Exception with specific exception types in remaining modules#1543
github-actions[bot] wants to merge 1 commit into
mainfrom
repo-assist/improve-specific-exceptions-20260526-8b235af0b7a94f1f

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This is an automated pull request from Repo Assist.

Summary

This PR is the companion to #1532. It replaces the remaining raise Exception calls with semantically correct specific exception types across 8 modules not covered by #1532.

Changes

File Change
dowhy/causal_identifier/id_identifier.py ExceptionValueError (2 sites: wrong value in get_val(), non-DAG graph)
dowhy/causal_prediction/algorithms/base_algorithm.py ExceptionValueError (invalid optimizer argument)
dowhy/do_samplers/kernel_density_sampler.py ExceptionNotImplementedError (abstract method subclasses must override)
dowhy/do_samplers/mcmc_sampler.py ExceptionValueError (3 sites: unrecognized variable type, non-DAG graph checks)
dowhy/api/causal_data_frame.py ExceptionValueError/TypeError (3 sites: invalid variable type, unrecognized input format)
dowhy/utils/api.py ExceptionTypeError (unrecognized parse_state format)
dowhy/utils/propensity_score.py ExceptionValueError (3 sites: unrecognized variable types)
dowhy/gcm/equation_parser.py ExceptionValueError (2 sites: invalid equation expressions)

Mapping rationale:

  • ValueError — wrong argument value or invalid data content
  • TypeError — wrong type or unrecognized format
  • NotImplementedError — abstract method that subclasses must implement

Test Status

  • black — all 8 files pass formatting check
  • isort — import order unchanged
  • flake8 — no new lint errors introduced (pre-existing warnings only)
  • pytest tests/ -m "not advanced and not econml and not notebook" — 188 passed, 13 skipped, 1 pre-existing failure (test_refutation_binary_treatment[...propensity_score_matching...] — verified fails on main without these changes; unrelated TypeError from numpy dtype casting)

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@11c9a2c442e519ff2b427bf58679f5a525353f76

…emaining modules

Replace bare `raise Exception` with semantically correct specific types
across 8 modules not covered by PR #1532:

- ValueError: wrong argument value, unrecognized variable type, invalid graph structure
- TypeError: unrecognized input format/type
- NotImplementedError: abstract method that subclasses must override

Files changed:
- dowhy/causal_identifier/id_identifier.py
- dowhy/causal_prediction/algorithms/base_algorithm.py
- dowhy/do_samplers/kernel_density_sampler.py
- dowhy/do_samplers/mcmc_sampler.py
- dowhy/api/causal_data_frame.py
- dowhy/utils/api.py
- dowhy/utils/propensity_score.py
- dowhy/gcm/equation_parser.py

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants