Skip to content

Migrate from os.path to pathlib for file path handling#654

Open
zliang-akamai wants to merge 3 commits intolinode:devfrom
zliang-akamai:zhiwei/pathlib-migration
Open

Migrate from os.path to pathlib for file path handling#654
zliang-akamai wants to merge 3 commits intolinode:devfrom
zliang-akamai:zhiwei/pathlib-migration

Conversation

@zliang-akamai
Copy link
Member

📝 Description

Migrate low-level OS APIs to pathlib for handling file paths.

✔️ How to Test

pytest ./test/unit/linode_client_test.py -k test_ssh_key_create
pytest test/unit/linode_client_test.py -k test_instance_create

@zliang-akamai zliang-akamai requested a review from a team as a code owner February 28, 2026 06:35
@zliang-akamai zliang-akamai requested review from dawiddzhafarov and ezilber-akamai and removed request for a team February 28, 2026 06:35
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 PR migrates several file-path handling call sites from os.path APIs to pathlib.Path, aligning the SDK and docs with modern Python path handling.

Changes:

  • Replaced os.path.isfile / os.path.expanduser checks with Path(...).expanduser().is_file() in key/cert loading helpers.
  • Updated StackScript file detection to use Path.is_file().
  • Updated Sphinx docs/conf.py to use pathlib when inserting the project root into sys.path.

Reviewed changes

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

Show a summary per file
File Description
linode_api4/objects/nodebalancer.py Uses Path(...).expanduser().is_file() for SSL cert/key file loading.
linode_api4/groups/profile.py Uses Path(...).expanduser().is_file() for SSH public key loading from a file.
linode_api4/groups/linode.py Uses Path.is_file() for StackScript “script is a file path” detection.
linode_api4/common.py Uses Path(...).expanduser().is_file() for authorized_keys file loading.
docs/conf.py Switches sys.path insertion to pathlib and updates the inline guidance comment.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

dawiddzhafarov
dawiddzhafarov previously approved these changes Mar 2, 2026
ezilber-akamai
ezilber-akamai previously approved these changes Mar 3, 2026
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.

4 participants