Skip to content

feat: allow file paths to be passed in as pathlike objects#198

Open
kimboleh wants to merge 3 commits into
tektronix:mainfrom
kimboleh:feature/accept-pathlike-objects
Open

feat: allow file paths to be passed in as pathlike objects#198
kimboleh wants to merge 3 commits into
tektronix:mainfrom
kimboleh:feature/accept-pathlike-objects

Conversation

@kimboleh

@kimboleh kimboleh commented Jun 25, 2026

Copy link
Copy Markdown

Proposed changes

Allows for functions/methods/classes to accept pathlib.Path objects in addition to just strings.

Addresses #33


Most of these changes involve simply adding a Union type to allow for either a str or a Path object type to be passed in as a file path. There are a couple of places where isinstance logic has been implemented to handle a possible non-string in the form of a Path object.

Most of the functionality is tested simply by passing Path objects to the read_file and write_file methods, as most other functions simply pass their file paths on to those functions, but I've added testing for Path objects throughout the tests just to be thorough. A secondary look to make sure I have thorough coverage would be welcome.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Functionality update (non-breaking change which updates or changes existing functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • CI/CD update (an update to the CI/CD workflows, scripts, and/or configurations)
  • Documentation update (an update to enhance the user experience when reading through the docs)

Checklist

  • I have followed the guidelines in the CONTRIBUTING document
  • I have signed the CLA
  • I have checked to ensure there aren't other open Pull Requests for the same update/change
  • I have created (or updated) an Issue to track the status of this update/change and updated the link in this PR description (see above in the Proposed changes section) using the wording Addresses #<issue_number>
  • I have performed a self-review of my code
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • Basic linting passes locally with my changes
  • Note: The safety pre-commit hook fails locally for me with cannot import name 'build_client_session' from 'safety.auth' - this reproduces on main and appears to be a pre-existing dependency issue, or possibly something on my machine. I bypassed it with --no-verify to commit, but please let me know if there's something I need to fix there.
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have added necessary documentation (if appropriate)
  • I have updated the Changelog with a brief description of my changes

@kimboleh
kimboleh requested a review from a team as a code owner June 25, 2026 01:42
@CLAassistant

CLAassistant commented Jun 25, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@kimboleh
kimboleh force-pushed the feature/accept-pathlike-objects branch from f1754b2 to c2cf697 Compare June 25, 2026 01:55
Comment thread pyproject.toml
@kimboleh
kimboleh force-pushed the feature/accept-pathlike-objects branch from c2cf697 to 4f75e84 Compare June 25, 2026 02:23
Comment thread src/tm_data_types/io_factory_methods.py Outdated
file_format: A specialized file format we are writing as.
"""
_, path_extension = os.path.splitext(path)
_, path_extension = os.path.splitext(file_path)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There might be a better way to do this if you convert it to a Path object

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I just pushed an update for this if you want to check it - definitely a cleaner way to handle things.

Comment thread tests/test_tm_data_types.py
Comment thread tests/test_tm_data_types.py
nfelt14
nfelt14 previously approved these changes Jun 25, 2026
@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown

Breaking API Changes

src/tm_data_types/io_factory_methods.py:30: write_file(path):
Parameter was removed

src/tm_data_types/io_factory_methods.py:30: write_file(file_path):
Parameter was added as required

Link to workflow run

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown

Test Results (macos)

path passed skipped subtotal
tests/test_tm_data_types.py 20 1 21
TOTAL 20 1 21
tests/test_tm_data_types.py
('/Users/runner/work/tm_data_types/tm_data_types/tests/test_tm_data_types.py', 602, 'Skipped: Skipping 1G test in GitHub Actions environment')

Link to workflow run

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown

Test Results (ubuntu)

path passed skipped subtotal
tests/test_tm_data_types.py 20 1 21
TOTAL 20 1 21
tests/test_tm_data_types.py
('/home/runner/work/tm_data_types/tm_data_types/tests/test_tm_data_types.py', 602, 'Skipped: Skipping 1G test in GitHub Actions environment')

Link to workflow run

@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown

Test Results (windows)

path passed skipped subtotal
tests\test_tm_data_types.py 20 1 21
TOTAL 20 1 21
tests\test_tm_data_types.py
('D:\\a\\tm_data_types\\tm_data_types\\tests\\test_tm_data_types.py', 602, 'Skipped: Skipping 1G test in GitHub Actions environment')

Link to workflow run

@kimboleh
kimboleh force-pushed the feature/accept-pathlike-objects branch from 4924791 to d46864d Compare June 25, 2026 23:30
@kimboleh
kimboleh requested a review from nfelt14 June 29, 2026 19:40
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