fix: replace bare except: with except Exception: in SDK#13084
fix: replace bare except: with except Exception: in SDK#13084harshadkhetpal wants to merge 3 commits intokubeflow:masterfrom
except: with except Exception: in SDK#13084Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @harshadkhetpal. Thanks for your PR. I'm waiting for a kubeflow member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
There was a problem hiding this comment.
Pull request overview
This PR updates exception handling patterns across three SDK files to comply with PEP 8 E722 by replacing bare except: clauses with except Exception:. This change improves code quality by allowing system exceptions like KeyboardInterrupt and SystemExit to propagate properly while still catching normal exceptions in fallback handling patterns.
Changes:
- Replace bare
except:withexcept Exception:in type conversion fallback (v1_modelbase.py) - Replace bare
except:withexcept Exception:in JSON parsing fallback (type_utils.py) - Replace bare
except:withexcept Exception:in Kubernetes config loading fallback (client.py - 2 occurrences)
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| sdk/python/kfp/dsl/v1_modelbase.py | Updates exception handling for type conversion fallback pattern |
| sdk/python/kfp/dsl/types/type_utils.py | Updates exception handling for JSON parsing fallback pattern |
| sdk/python/kfp/client/client.py | Updates exception handling for Kubernetes config loading fallback patterns (2 locations) |
Summary
Replace bare
except:clauses withexcept Exception:across three SDK files to comply with PEP 8 E722.Bare
exceptclauses catch everything includingKeyboardInterruptandSystemExit, which is rarely intended for fallback/default handling.Files changed:
sdk/python/kfp/dsl/v1_modelbase.py(line 135): type conversion fallbacksdk/python/kfp/client/client.py(lines 305, 316): k8s config loading fallbacksdk/python/kfp/dsl/types/type_utils.py(line 113): JSON parsing fallbackTesting
No behavior change for normal exceptions —
except Exception:covers all standard exceptions while allowingKeyboardInterruptandSystemExitto propagate correctly.