[Repo Assist] improve: replace generic Exception with specific exception types in remaining modules#1543
Draft
github-actions[bot] wants to merge 1 commit into
Conversation
…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>
This was referenced May 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated pull request from Repo Assist.
Summary
This PR is the companion to #1532. It replaces the remaining
raise Exceptioncalls with semantically correct specific exception types across 8 modules not covered by #1532.Changes
dowhy/causal_identifier/id_identifier.pyException→ValueError(2 sites: wrong value inget_val(), non-DAG graph)dowhy/causal_prediction/algorithms/base_algorithm.pyException→ValueError(invalid optimizer argument)dowhy/do_samplers/kernel_density_sampler.pyException→NotImplementedError(abstract method subclasses must override)dowhy/do_samplers/mcmc_sampler.pyException→ValueError(3 sites: unrecognized variable type, non-DAG graph checks)dowhy/api/causal_data_frame.pyException→ValueError/TypeError(3 sites: invalid variable type, unrecognized input format)dowhy/utils/api.pyException→TypeError(unrecognizedparse_stateformat)dowhy/utils/propensity_score.pyException→ValueError(3 sites: unrecognized variable types)dowhy/gcm/equation_parser.pyException→ValueError(2 sites: invalid equation expressions)Mapping rationale:
ValueError— wrong argument value or invalid data contentTypeError— wrong type or unrecognized formatNotImplementedError— abstract method that subclasses must implementTest Status
black— all 8 files pass formatting checkisort— import order unchangedflake8— 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 onmainwithout these changes; unrelatedTypeErrorfrom numpy dtype casting)