Merged
Conversation
Closed
There was a problem hiding this comment.
Pull request overview
This PR refactors envstack.path to improve template lookup/matching and environment-variable expansion by loading and using resolved envstack stacks, and adds new tests and an example template entry.
Changes:
- Added stack-aware helpers for env-var escaping/expansion and resolved stack loading; updated
get_template()andmatch_template()accordingly. - Refactored
Path/TemplateAPIs (notablyPath.to_platform()andTemplate.apply_fields()returningPath) and updated convenience helpers likeextract_fields(). - Added
tests/test_path.pycoverage for the new template resolution/matching behavior and aNUKESCRIPTexample template.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
lib/envstack/path.py |
Major refactor: resolved-stack loading, env-var expansion/escaping, updated template matching and platform conversion APIs. |
tests/test_path.py |
New unit tests covering template expansion, matching specificity, field extraction, and platform root rewriting. |
examples/default/test.env |
Adds a NUKESCRIPT example path template for demonstration/testing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request significantly refactors and extends the
envstack.pathmodule to improve path template handling, environment variable expansion, and template matching. The changes introduce more robust and flexible functions for loading templates, converting paths between platforms, and extracting or matching template fields. Several convenience functions are enhanced to allow for more explicit stack, platform, and scope selection, and error handling is improved throughout.Enhancements to path template handling and environment variable expansion:
_escape_env_varsand_expand_env_varshelpers to properly handle and expand environment variables within template strings, allowing for both literal and expanded usage as needed. [1] [2]get_templateandmatch_templatefunctions to explicitly load and resolve environment stacks, expand variables, and allow for stack, platform, and scope overrides. [1] [2]Refactoring and API improvements:
Pathclass to support more robust platform conversion via the newto_platformmethod, which loads environment stacks for both source and target platforms and replaces root directories accordingly.Templateclass and its methods, includingapply_fields(now returns aPath), and improved error handling inget_fields. [1] [2] [3] [4]Convenience and utility function improvements:
extract_fields,get_scope, and related utilities to use the new stack-aware APIs and provide better error reporting._iter_template_itemsfor heuristically discovering likely path templates in an environment, making template matching more flexible and not reliant on a special namespace.Configuration and environment changes:
NUKESCRIPTpath template to the test environment file for demonstration and testing.These changes make the path template system more powerful, extensible, and easier to use in multi-platform, stack-based environments.