Fix: Improve Python code quality and PEP 8 compliance#2632
Merged
pcarruscag merged 2 commits intosu2code:developfrom Nov 29, 2025
Merged
Fix: Improve Python code quality and PEP 8 compliance#2632pcarruscag merged 2 commits intosu2code:developfrom
pcarruscag merged 2 commits intosu2code:developfrom
Conversation
- Replace improper `== None` and `!= None` comparisons with `is None` and `is not None` in multiple files. - Replace bare `except:` clauses with specific `except OSError:` in `topology_optimization.py`. Signed-off-by: shbhmexe <shubhushukla586@gmail.com>
Author
|
/label code-quality |
Replaces OSError with Exception in several try-except blocks to catch a broader range of errors during file operations and subprocess calls. Adds comments to clarify that file removal errors are ignored if the file does not exist. Signed-off-by: shbhmexe <shubhushukla586@gmail.com>
pcarruscag
approved these changes
Nov 29, 2025
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.
Proposed Changes
This PR addresses several code quality issues in the Python codebase to improve PEP 8 compliance and robustness.
Specific changes:
== Noneand!= Nonewithis Noneandis not Nonein:SU2_PY/SU2_CFD.pySU2_PY/parallel_computation.pySU2_PY/parallel_computation_fsi.pySU2_PY/topology_optimization.pySU2_PY/SU2/io/data.pySU2_PY/topology_optimization.pyto avoid bareexcept:clauses:except OSError:foros.removecalls (handling file not found, permission errors).except Exception:for solver execution and parsing blocks (preserving original catch-all behavior for runtime errors but allowing system interrupts like Ctrl+C to propagate).Related Work
PR Checklist
Put an X by all that apply. You can fill this out after submitting the PR. If you have any questions, don't hesitate to ask! We want to help. These are a guide for you to know what the reviewers will be looking for in your contribution.
pre-commit run --allto format old commits.