fix: Python 3 correctness and PEP 8 compliance improvements#2640
Merged
pcarruscag merged 5 commits intosu2code:developfrom Dec 9, 2025
Merged
fix: Python 3 correctness and PEP 8 compliance improvements#2640pcarruscag merged 5 commits intosu2code:developfrom
pcarruscag merged 5 commits intosu2code:developfrom
Conversation
- Use identity operators for None comparisons (is/is not) - Replace bare except with Exception/OSError - Replace .has_key() and .iteritems() with Python 3 equivalents - Fix mutable default arguments in function signatures Signed-off-by: shbhmexe <shubhushukla586@gmail.com>
Author
|
/label changelog:chore |
Signed-off-by: shbhmexe <shubhushukla586@gmail.com>
pcarruscag
reviewed
Dec 9, 2025
added 2 commits
December 9, 2025 15:01
….projection - tools.py: update restart2solution docstring to match signature (state=None), per review. - projection.py: clarify that the 'state' parameter is accepted for API compatibility and currently unused. - No functional changes. Signed-off-by: shbhmexe <shubhushukla586@gmail.com>
…odeQL/CodeFactor) - Replace three `try/except ...: pass` blocks with existence checks before os.remove. - No behavioral change; resolves “Unreachable except block” and “Empty except” findings. Signed-off-by: shbhmexe <shubhushukla586@gmail.com>
pcarruscag
approved these changes
Dec 9, 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.
This PR fixes Python code quality issues in SU2_PY without changing behavior.
None Comparisons (PEP 8 E711)
Fixed improper None comparisons using identity operators:
not x is None→x is not None(interface.py, state.py)== None→is None(SU2_CFD.py, parallel_computation.py, data.py, topology_optimization.py)!= None→is not None(SU2_CFD.py, data.py)Bare Except Clauses (PEP 8 E722)
Replaced bare
except:with specific exceptions in topology_optimization.py:except OSError:for file removal operationsexcept Exception:for general error handlingDeprecated Python 2 Methods
.has_key(key)→key in dict(data.py).iteritems()→.items()(data.py)Mutable Default Arguments
Fixed shared-state bugs by replacing mutable defaults with None:
restart2solution(state={})→restart2solution(state=None)projection(state={})→projection(state=None)tecplot(keys_plot=[])→tecplot(keys_plot=None)Files Modified (10 files)
data.py,state.py,tools.py,interface.py,projection.py,plot.py,SU2_CFD.py,parallel_computation.py,parallel_computation_fsi.py,topology_optimization.py