feat: ✨ Add ProfileLoader.required_module_names method#253
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a new method to collect all required module names, including their nested subsets, and adds tests for both default and named scenarios.
- Implemented
ProfileLoader.required_module_nameswith a helper__walk_subsets_for. - Added two unit tests to verify the returned set of module names.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/loaders/test_profile_loader.py | Added tests for default and named required modules |
| injection/loaders.py | Implemented required_module_names and subset walker |
Comments suppressed due to low confidence (3)
injection/loaders.py:158
- [nitpick] The generator expression reuses
name, shadowing the method parameter. Rename the inner loop variable (e.g.for module_name in names) to avoid confusion.
subsets = (self.__walk_subsets_for(name) for name in names)
tests/loaders/test_profile_loader.py:14
- Calling
mod()multiple times produces distinct modules with different names. Assign a single module instance to a variable (e.g.module = mod()), usemodule.namein the mapping, and then reuse that same variable in the expected set to ensure consistency.
mod().name: ["a", "b", "c"],
tests/loaders/test_profile_loader.py:21
- Same issue as above: this call to
mod().namecreates a new instance. Reference the earliermodulevariable to compare the correct name.
mod().name,
| def __is_empty(self) -> bool: | ||
| return not self.module_subsets | ||
|
|
||
| def required_module_names(self, name: str | None = None, /) -> frozenset[str]: |
There was a problem hiding this comment.
[nitpick] Consider adding a docstring for required_module_names to explain its parameters (including name=None) and the structure of its return value, making its behavior clearer to future readers.
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.
No description provided.