Apply match-case instead of if-elif - #4599
Conversation
… improve error handling for illegal model types
…mproved readability and maintainability
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4599 +/- ##
==========================================
- Coverage 49.99% 49.88% -0.11%
==========================================
Files 151 151
Lines 29916 30068 +152
==========================================
+ Hits 14956 15000 +44
- Misses 14960 15068 +108 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…s.py, pfcoil.py, and superconducting.py
…d TF conductor model
…constraints.py, hcpb.py, confinement_time.py, profiles.py, power.py, and base.py
…lity in superconductor model logic and process checks
…y in divertor configuration and tokamak aspect ratio logic
7558d0c to
4c03360
Compare
clmould
left a comment
There was a problem hiding this comment.
Much nicer with match-case than all the if-elses! :)
One more thing - could any return types that have been added be changed to : please ? In the docs it will render with : as long as the return type has been typed in the function definition with -> (https://ukaea.github.io/PROCESS/development/standards/#docstrings)
clmould
left a comment
There was a problem hiding this comment.
Also some unresolved comments about adding the _missing_ methods for ConfinementRadiationLossModel, ConfinementTimeModel, PlasmaCurrentModel, PlasmaGeometryModelType to remove the try-excepts, but happy with the rest
…mproving code clarity and structure
Description
Since we now require Python
>=3.10we should usematch-casestatements overif-elsebecause it supports structural pattern matching, avoids repeating the same variable name, and makes complex conditional checks much easier to readChecklist
I confirm that I have completed the following checks: