Skip to content

Simplify re init#1561

Merged
amilcarlucas merged 3 commits into
masterfrom
simplify_re-init
Apr 27, 2026
Merged

Simplify re init#1561
amilcarlucas merged 3 commits into
masterfrom
simplify_re-init

Conversation

@amilcarlucas
Copy link
Copy Markdown
Collaborator

Description

Refactor for consistency

Checklist

  • Run pre-commit checks locally
  • Verified by a human programmer
  • All commits are signed off (use git commit --signoff)
  • Code follows our coding standards
  • Documentation updated if needed
  • No breaking changes or properly documented

Testing

Describe how you tested these changes:

  • Unit tests pass
  • Integration tests pass
  • Manual testing performed
  • Tested on flight controller hardware

Copilot AI review requested due to automatic review settings April 27, 2026 21:55
Copy link
Copy Markdown
Contributor

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

Note

Copilot was unable to run its full agentic suite in this review.

Refactors how parameter default values are stored/updated during initialization and when writing defaults to disk, aligning call sites and tests for consistency.

Changes:

  • Renamed write_param_default_values to set_param_default_values_if_different and updated call sites.
  • Extended write_param_default_values_to_file to support writing defaults into an explicit target vehicle_dir.
  • Updated unit tests and documentation to reflect the renamed API and revised initialization behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/test_data_model_vehicle_project.py Updates mocks to match the new write_param_default_values_to_file call signature.
tests/test_backend_filesystem.py Renames/updates the unit test to cover set_param_default_values_if_different.
tests/test__main__.py Updates initialization test to use/verify set_param_default_values_if_different.
ardupilot_methodic_configurator/backend_filesystem.py Renames default-setting API and extends default-file writing to allow explicit destination directory.
ardupilot_methodic_configurator/main.py Uses the renamed default-setting API during filesystem initialization.
USECASES.md Updates the initialization steps documentation to include the additional checkbox.

Comment thread ardupilot_methodic_configurator/backend_filesystem.py
Comment on lines +1001 to +1005
self, param_default_values: ParDict, filename: str = "00_default.param", vehicle_dir: str = ""
) -> None:
if self.set_param_default_values_if_different(param_default_values):
if len(vehicle_dir) == 0:
vehicle_dir = self.vehicle_dir
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

Using an empty string sentinel plus len(vehicle_dir) == 0 is brittle and non-idiomatic. Prefer vehicle_dir: Optional[str] = None (or a Path | None) and a simple vehicle_dir = vehicle_dir or self.vehicle_dir check; this also avoids a hard failure if a caller ever passes None.

Suggested change
self, param_default_values: ParDict, filename: str = "00_default.param", vehicle_dir: str = ""
) -> None:
if self.set_param_default_values_if_different(param_default_values):
if len(vehicle_dir) == 0:
vehicle_dir = self.vehicle_dir
self, param_default_values: ParDict, filename: str = "00_default.param", vehicle_dir: Optional[str] = None
) -> None:
if self.set_param_default_values_if_different(param_default_values):
vehicle_dir = vehicle_dir or self.vehicle_dir

Copilot uses AI. Check for mistakes.
mock_open.assert_called_once_with("/vehicles/my_flight")
# Assert: extracted defaults written (replacing the template's 00_default.param)
mock_write.assert_called_once_with(fake_defaults)
mock_write.assert_called_once_with(fake_defaults, "00_default.param", "/vehicles/my_flight")
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

These assertions depend on positional argument order for a function that now has multiple optional parameters. Using keyword arguments in assert_called_once_with(...) would make the tests more robust against future signature/order changes while still verifying the same behavior.

Copilot uses AI. Check for mistakes.

# Assert: the extracted defaults — not the template's — are written
mock_write.assert_called_once_with(fake_defaults)
mock_write.assert_called_once_with(fake_defaults, "00_default.param", "/vehicles/flight")
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

These assertions depend on positional argument order for a function that now has multiple optional parameters. Using keyword arguments in assert_called_once_with(...) would make the tests more robust against future signature/order changes while still verifying the same behavior.

Suggested change
mock_write.assert_called_once_with(fake_defaults, "00_default.param", "/vehicles/flight")
mock_write.assert_called_once()
args, kwargs = mock_write.call_args
assert kwargs == {}
assert args[0] == fake_defaults
assert args[1] == "00_default.param"
assert args[2] == "/vehicles/flight"

Copilot uses AI. Check for mistakes.
…ers dict

This should fix a double 00_default.param file inside the "Zip files for forum help" zip file
…nections from FC Parameters, not from template files reference
@amilcarlucas amilcarlucas merged commit 3257c14 into master Apr 27, 2026
24 of 27 checks passed
@amilcarlucas amilcarlucas deleted the simplify_re-init branch April 27, 2026 23:21
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 28, 2026

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
12586 11860 94% 89% 🟢

New Files

No new covered files...

Modified Files

No covered modified files...

updated for commit: 01d1ceb by action🐍

@coveralls
Copy link
Copy Markdown

Coverage Report for CI Build 25024542293

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.1%) to 95.614%

Details

  • Coverage increased (+0.1%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 13680
Covered Lines: 13080
Line Coverage: 95.61%
Relevant Branches: 2334
Covered Branches: 2265
Branch Coverage: 97.04%
Branches in Coverage %: No
Coverage Strength: 3.43 hits per line

💛 - Coveralls

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.

3 participants