Skip to content

Conversation

@tibisabau
Copy link

@tibisabau tibisabau commented Dec 16, 2025

Summary

This PR refactors if/elif/else chains to use Python 3.10's match-case pattern matching syntax, improving code readability and maintainability. Closes #725.

This code was generated using Claude Sonnet 4.5.

Changes

  • Replaced if/elif/else chains with match-case statements.
  • Updated ruff target version to Python 3.10

Pull request type

  • Code changes (bugfix, features)
  • Code maintenance (refactoring, formatting, tests)

@tibisabau tibisabau marked this pull request as ready for review December 16, 2025 12:13
@tibisabau tibisabau requested a review from a team as a code owner December 16, 2025 12:13
Copilot AI review requested due to automatic review settings December 16, 2025 12:13
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors if/elif/else chains to use Python 3.10's match-case pattern matching syntax across multiple files and updates the ruff target version to Python 3.10. While most conversions are correct, there are critical logic errors in the refactoring that change the behavior of the code.

  • Converted if/elif/else chains to match-case statements in 7 files
  • Updated ruff target version from py39 to py310
  • Introduced critical bug in environment.py from_dict method that changes execution logic

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pyproject.toml Updated ruff target version from py39 to py310
rocketpy/units.py Converted axis label matching (0/1) to match-case
rocketpy/rocket/rocket.py Converted coordinate system orientation validation to match-case
rocketpy/rocket/aero_surface/nose_cone.py Converted nose cone kind validation to match-case with OR patterns
rocketpy/plots/rocket_plots.py Converted plane coordinate mapping to match-case (2 functions)
rocketpy/motors/motor.py Converted coordinate system orientation validation to match-case
rocketpy/mathutils/function.py Converted interpolation/extrapolation type selection to match-case; incomplete refactoring in plot_2d method; missing default case in differentiate
rocketpy/environment/environment.py Converted atmospheric model type handling to match-case; critical bug in from_dict where code moved outside match statement

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Member

@Gui-FernandesBR Gui-FernandesBR left a comment

Choose a reason for hiding this comment

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

@tibisabau can you update CHANGELOG.md file please?

@Gui-FernandesBR
Copy link
Member

@tibisabau we need all the tests to be green on CI

Copy link
Member

@Gui-FernandesBR Gui-FernandesBR left a comment

Choose a reason for hiding this comment

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

LGTM,

I will merge it if all tests pass.

@tibisabau could you run slow tests and share the evidence here?

@tibisabau
Copy link
Author

LGTM,

I will merge it if all tests pass.

@tibisabau could you run slow tests and share the evidence here?

all tests:
image

slow tests:
image

@codecov
Copy link

codecov bot commented Dec 16, 2025

Codecov Report

❌ Patch coverage is 81.18081% with 51 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.09%. Comparing base (9cf3dd4) to head (c92dacc).
⚠️ Report is 26 commits behind head on develop.

Files with missing lines Patch % Lines
rocketpy/environment/environment.py 66.07% 19 Missing ⚠️
rocketpy/mathutils/function.py 89.54% 16 Missing ⚠️
rocketpy/plots/rocket_plots.py 61.11% 7 Missing ⚠️
rocketpy/units.py 0.00% 5 Missing ⚠️
rocketpy/rocket/aero_surface/nose_cone.py 86.20% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #921      +/-   ##
===========================================
+ Coverage    80.27%   81.09%   +0.82%     
===========================================
  Files          104      107       +3     
  Lines        12769    13833    +1064     
===========================================
+ Hits         10250    11218     +968     
- Misses        2519     2615      +96     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Gui-FernandesBR
Copy link
Member

@tibisabau please fix linters so we can merge this PR

@Gui-FernandesBR
Copy link
Member

amazing implementation!

@Gui-FernandesBR Gui-FernandesBR merged commit ba77fd5 into RocketPy-Team:develop Dec 16, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENH: use the match operator once python 3.9 is no longer supported

2 participants