Skip to content

Conversation

@amilcarlucas
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings September 18, 2025 10:54
Copy link
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

This pull request modernizes the codebase by replacing os.path and os module calls with pathlib.Path operations, providing better performance and more readable code.

Key changes:

  • Replaces all os.path operations with equivalent pathlib.Path methods
  • Removes unused os module imports
  • Improves code readability and maintainability through modern Python path handling

Comment on lines +461 to +462
# Use pathlib for cleaner path operations
return Path(full_path).name
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

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

The function name get_directory_name_from_full_path suggests it should return a directory name, but Path.name returns the final component of the path (which could be a file). The original code used os.path.basename(os.path.split(normalized_path)[1]) which had different behavior. This change may break functionality if callers expect directory-specific behavior.

Suggested change
# Use pathlib for cleaner path operations
return Path(full_path).name
# Return the name of the parent directory, even if the path ends with a file
return Path(full_path).parent.name

Copilot uses AI. Check for mistakes.
capture_output=True,
text=True,
cwd=os_path.dirname(__file__),
cwd=Path(__file__).parent,
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

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

The cwd parameter expects a string path, but Path(__file__).parent returns a Path object. This should be converted to string: cwd=str(Path(__file__).parent)

Suggested change
cwd=Path(__file__).parent,
cwd=str(Path(__file__).parent),

Copilot uses AI. Check for mistakes.
git_hash_file = os_path.join(os_path.dirname(__file__), "git_hash.txt")
git_hash_file = Path(__file__).parent / "git_hash.txt"
try:
with open(git_hash_file, encoding="utf-8") as file:
Copy link

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

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

The open() function expects a string path, but git_hash_file is a Path object. Convert to string: with open(str(git_hash_file), encoding=\"utf-8\") as file:

Suggested change
with open(git_hash_file, encoding="utf-8") as file:
with open(str(git_hash_file), encoding="utf-8") as file:

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Contributor

github-actions bot commented Sep 18, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
8558 6869 80% 80% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
ardupilot_methodic_configurator/backend_filesystem.py 73% 🟢
TOTAL 73% 🟢

updated for commit: db41783 by action🐍

@github-actions
Copy link
Contributor

github-actions bot commented Sep 18, 2025

Test Results

    1 files   -     1      1 suites   - 1   58s ⏱️ -49s
1 883 tests ±    0  1 859 ✅  -    23  1 💤 ±0  23 ❌ +23 
1 883 runs   - 1 883  1 859 ✅  - 1 905  1 💤  - 1  23 ❌ +23 

For more details on these failures, see this check.

Results for commit db41783. ± Comparison against base commit c0d7d34.

♻️ This comment has been updated with latest results.

@amilcarlucas amilcarlucas force-pushed the pathlib_and_perf branch 2 times, most recently from 3541d9c to d783fcd Compare September 19, 2025 14:35
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.

2 participants