FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: Replace bare except blocks with specific exception types by Robbie-Palmer · Pull Request #1348 · openapi-generators/openapi-python-client · GitHub

Repository navigation

fix: Replace bare except blocks with specific exception types - #1348

Merged
dbanty merged 2 commits into
openapi-generators:mainfrom
Robbie-Palmer:fix/bare-except-blocks
Oct 31, 2025
Merged

dbanty merged 2 commits into
openapi-generators:mainfrom
Robbie-Palmer:fix/bare-except-blocks

Conversation

Copy link
Copy Markdown
Contributor

Summary

Replace bare except: blocks with specific exception tuple except (TypeError, ValueError, AttributeError, KeyError): in the union property parsing template.

Changes

  • Updated openapi_python_client/templates/property_templates/union_property.py.jinja:24 to catch only specific exceptions relevant to parsing operations
  • Removed # noqa: E722 linting suppression comments that are no longer needed
  • Regenerated all golden records to reflect template changes

Benefits

  • Makes error handling more explicit and intentional
  • Avoids catching system exceptions like KeyboardInterrupt or SystemExit
  • Improves code quality and complies with PEP 8 style guidelines
  • Removes the need for linting suppressions

Test plan

  • Regenerated golden records with pdm regen
  • Verified all generated model files with union properties now use specific exception handling
  • Confirmed the exception tuple covers the relevant error cases for parsing (TypeError, ValueError, AttributeError, KeyError)

Replace bare `except:` with specific exception tuple `except (TypeError, ValueError, AttributeError, KeyError):` in union property parsing template. This improves code quality by:

- Making error handling more explicit and intentional
- Avoiding catching system exceptions like KeyboardInterrupt or SystemExit
- Removing the need for noqa: E722 linting suppressions
- Making the code comply with PEP 8 style guidelines

All generated models with union properties now use specific exception handling in their _parse functions.
Robbie-Palmer force-pushed the fix/bare-except-blocks branch from b5e43a7 to 63fbbff Compare October 31, 2025 16:04

dbanty left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Lovely, thanks!

dbanty added this pull request to the merge queue Oct 31, 2025
Merged via the queue into openapi-generators:main with commit 72e4efe Oct 31, 2025
knope-bot Bot mentioned this pull request Oct 31, 2025
Robbie-Palmer deleted the fix/bare-except-blocks branch October 31, 2025 16:20
github-merge-queue Bot pushed a commit that referenced this pull request Nov 3, 2025
> [!IMPORTANT]
> Merging this pull request will create this release

## Fixes

- Remove non-existent CHANGELOG.md references from UV and Poetry
templates (#1344)
- Initialize optional lists as UNSET, not [] (#1346)
- Correct docstring typos in client template (#1347)
- Replace bare except blocks with specific exception types (#1348)

### Update `uv_build` to 0.9

#1352 by @johnthagen

`uv` has been in the `0.9.x` release cycle for a while, so update
templates to use the corresponding `uv_build` range.

Co-authored-by: knope-bot[bot] <152252888+knope-bot[bot]@users.noreply.github.com>
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL