Skip to content

fix: Replace bare except clauses with specific exception types in Python utilities#2633

Merged
pcarruscag merged 2 commits intosu2code:developfrom
shbhmexe:fix/python-bare-except-clauses
Dec 2, 2025
Merged

fix: Replace bare except clauses with specific exception types in Python utilities#2633
pcarruscag merged 2 commits intosu2code:developfrom
shbhmexe:fix/python-bare-except-clauses

Conversation

@shbhmexe
Copy link

@shbhmexe shbhmexe commented Nov 30, 2025

Fixes remaining bare except clauses to improve PEP 8 compliance and code robustness:

  • SU2/init.py: Use ImportError for optional readline import.
  • SU2/io/config.py: Use Exception for config file error handling.
  • SU2/util/ordered_bunch.py: Use Exception and (KeyError, TypeError).
  • SU2/util/bunch.py: Use Exception and (KeyError, TypeError).

This commit improves PEP 8 compliance and code robustness by replacing
bare except clauses with specific exception types in Python utility files.

Changes:
- SU2/__init__.py: Use ImportError for optional readline import
- SU2/io/config.py: Use Exception for config file error handling
- SU2/util/ordered_bunch.py: Use Exception and (KeyError, TypeError)
- SU2/util/bunch.py: Use Exception and (KeyError, TypeError)

These changes maintain the original error-handling behavior while making
exception handling more explicit and maintainable. All modified files
pass Python syntax validation.

Signed-off-by: shbhmexe <shubhushukla586@gmail.com>
@shbhmexe
Copy link
Author

/label code-quality

@bigfooted
Copy link
Contributor

Thanks! There is no need to write these long descriptions for these simple changes - I guess they are chat descriptions? You can leave the bullet point description.

@shbhmexe
Copy link
Author

Thanks! There is no need to write these long descriptions for these simple changes - I guess they are chat descriptions? You can leave the bullet point description.

Thanks for the feedback! I'll keep the descriptions concise and stick to bullet points for simple changes in the future. I included the detailed description just to ensure I was strictly following the PR template guidelines.

@shbhmexe
Copy link
Author

shbhmexe commented Dec 1, 2025

Thanks! There is no need to write these long descriptions for these simple changes - I guess they are chat descriptions? You can leave the bullet point description.

Any other changes needed in this PR?

Signed-off-by: shbhmexe <shubhushukla586@gmail.com>
@shbhmexe
Copy link
Author

shbhmexe commented Dec 2, 2025

Any other fixes required?

@pcarruscag
Copy link
Member

Maintaining SU2 is not a full-time job for any of us. I don't need daily reminders to merge 7 line changes.

@pcarruscag pcarruscag merged commit dac92cc into su2code:develop Dec 2, 2025
37 checks passed
@shbhmexe
Copy link
Author

shbhmexe commented Dec 2, 2025

@pcarruscag Got it, thanks for the clarification. I understand maintaining SU2 isn’t a full-time job and I’ll avoid sending reminders. Next time, I’ll focus on more substantial/core fixes when I get . Thanks for reviewing .

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.

3 participants