Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ✨ add path_*() functions (with their verify_*()'ers) #730

Merged
merged 22 commits into from
Oct 2, 2024

Conversation

signekb
Copy link
Member

@signekb signekb commented Sep 24, 2024

Description

I decided to have a script for path functions related to packages and one related to resources. I found that it became too long - for my taste at least - with the docstrings otherwise.

To add existing ID's to the raised errors, I have added two verify functions.

To test the path functions, I have created some helper functions to create the directory structure of packages and resources.

Closes #714

Reviewer Focus

This PR needs an in-depth review.

Checklist

  • Added or updated tests
  • Tests passed locally
  • Linted and formatted code
  • Build passed locally
  • Updated documentation (= docstrings)

The utility functions expands on the raised error to include existing ID's.
The utility functions make it easier to create the folder structure of packages and resources for testing the `path_()*` functions.
@signekb signekb changed the title feat: ✨ add path_*() functions with utils feat: ✨ add path_*() functions with helper functions Sep 25, 2024
@signekb signekb marked this pull request as draft September 25, 2024 07:23
@signekb signekb marked this pull request as ready for review September 25, 2024 07:36
Copy link
Contributor

@martonvago martonvago left a comment

Choose a reason for hiding this comment

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

Really nice!! Just some comments 😊

sprout/core/path_resource_functions.py Outdated Show resolved Hide resolved
sprout/core/path_error_context.py Outdated Show resolved Hide resolved
sprout/core/path_error_context.py Outdated Show resolved Hide resolved
sprout/core/path_package_functions.py Show resolved Hide resolved
sprout/core/path_package_functions.py Outdated Show resolved Hide resolved
sprout/core/path_resource_functions.py Show resolved Hide resolved
tests/core/directory_structure_setup.py Outdated Show resolved Hide resolved
tests/core/directory_structure_setup.py Outdated Show resolved Hide resolved
tests/core/directory_structure_setup.py Outdated Show resolved Hide resolved
tests/core/test_path_package_functions.py Outdated Show resolved Hide resolved
lwjohnst86
lwjohnst86 previously approved these changes Sep 30, 2024
Copy link
Member

@lwjohnst86 lwjohnst86 left a comment

Choose a reason for hiding this comment

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

@martonvago and @signekb I refactored the verify function into two, because the original one was confusing to me and had too many arguments for the purpose I interpreted it had. Makes the code a bit cleaner.

sprout/core/path_package_functions.py Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

I split the original verify function into two rather than one, and simplified them a lot. The original confused me.

@lwjohnst86 lwjohnst86 changed the title feat: ✨ add path_*() functions with helper functions feat: ✨ add path_*() functions (with their verify_*()'ers) Sep 30, 2024
Copy link
Contributor

@martonvago martonvago left a comment

Choose a reason for hiding this comment

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

Looks great! Just a tiny comment.

Only other thing I can think of is that FileNotFoundErrors are not being tested, but we can add those tests later too.

A Path to the resources within the package.
"""
path = path_package(package_id) / "resources"
verify_is_package_dir(path.parent)
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't path_package already do this (meaning this will never throw)?

lwjohnst86
lwjohnst86 previously approved these changes Oct 2, 2024
Copy link
Member

@lwjohnst86 lwjohnst86 left a comment

Choose a reason for hiding this comment

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

@martonvago since the verify_is_file() already has a unit test for it, I'm not too worried that we don't test that the files exist or not for these tests.

sprout/core/path_resource_functions.py Outdated Show resolved Hide resolved
@lwjohnst86 lwjohnst86 merged commit 71d8a4b into main Oct 2, 2024
@lwjohnst86 lwjohnst86 deleted the feat/add-path-functions branch October 2, 2024 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Create and test path_*()
3 participants