GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: Replace bare except blocks with specific exception types by Robbie-Palmer · Pull Request #1348 · openapi-generators/openapi-python-client

Conversation

@Robbie-Palmer

@Robbie-Palmer Robbie-Palmer commented Oct 31, 2025

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)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Robbie-Palmer added 2 commits October 31, 2025 15:56
@Robbie-Palmer
fix: Replace bare except blocks with specific exception types
6cddd8c
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
Merge remote-tracking branch 'upstream/main' into fix/bare-except-blocks
63fbbff
@Robbie-Palmer
Robbie-Palmer force-pushed the fix/bare-except-blocks branch from b5e43a7 to 63fbbff Compare October 31, 2025 16:04
dbanty
dbanty approved these changes Oct 31, 2025
View reviewed changes

@dbanty dbanty left a comment

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Lovely, thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Robbie-Palmer reacted with heart emoji
All reactions
  • ❤️ 1 reaction
@dbanty
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 knope-bot Bot mentioned this pull request Oct 31, 2025
Release 0.27.1 #1345
Merged
@Robbie-Palmer
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
@knope-bot
Release 0.27.1 (#1345)
c41e22a
> [!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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@dbanty dbanty dbanty approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Robbie-Palmer @dbanty
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.