Skip to content

feat: add module support to JustfileFixture#5

Open
bluefing wants to merge 1 commit intoDataBooth:mainfrom
bluefing:feat/module-support
Open

feat: add module support to JustfileFixture#5
bluefing wants to merge 1 commit intoDataBooth:mainfrom
bluefing:feat/module-support

Conversation

@bluefing
Copy link
Copy Markdown

@bluefing bluefing commented Apr 8, 2026

Adds module-aware recipe resolution to JustfileFixture. Recipes from nested modules are flattened by namepath (e.g. infra::deploy::up), so all existing methods work transparently with full module paths.

Closes #1

Changes

  • _flattened — cached single-pass walk of the dump, returning both recipes and modules
  • _recipes — now returns the flattened dict keyed by namepath (was root-only)
  • _flatten — static recursive walk of the module tree
  • all_modules — property returning discovered module paths
  • Backwards compatible — justfiles without modules work unchanged

Tests

9 tests covering: namepath flattening, privacy across modules, dependencies, parameters, unknown namepath errors, module discovery, private recipe filtering, and standalone _flatten usage.

@semanticdiff-com
Copy link
Copy Markdown

semanticdiff-com bot commented Apr 8, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  src/pytest_just/fixture.py  8% smaller
  tests/test_module_fixture.py  0% smaller

@bluefing bluefing force-pushed the feat/module-support branch from 944eeeb to 0e816cb Compare April 8, 2026 12:19
Flattens the nested module tree from just --dump into a flat dict keyed
by recipe namepaths (e.g. module::submodule::recipe). All existing
methods (is_private, dependencies, parameters, etc.) work transparently
with full module paths. Adds all_modules property for module discovery.

Backwards compatible — justfiles without modules work unchanged.
@bluefing bluefing force-pushed the feat/module-support branch from 0e816cb to 46a61b3 Compare April 8, 2026 13:12
@Mjboothaus
Copy link
Copy Markdown
Contributor

Great direction and this adds high-value capability for modular justfile layouts.

Assessment
• Alignment: High strategic value
• Risk: Low–Medium (correctness/integrity edge cases)

What looks good
• Useful module-aware recipe resolution.
• Strong coverage intent across flattening, module discovery, and lookups.

Points to consider before merge

  1. Collision handling: can we add explicit detection/error on duplicate flattened namepaths?
  2. Strictness: should malformed module payloads fail fast rather than being skipped?
  3. Dependency semantics: should dependency APIs return local names, qualified namepaths, or both?
  4. Naming consistency: PR description references all_modules, implementation uses module_namepaths - can we standardise wording.

@bluefing
Copy link
Copy Markdown
Author

bluefing commented Apr 10, 2026

Collision handling: can we add explicit detection/error on duplicate flattened namepaths?

Just does not allow duplicates, if I duplicate a recipe the in the same module I get this error

❯ just                          
error: Recipe `down` first defined on line 90 is redefined on line 105
   ——▶ .just/docker/compose/mod.just:105:2
    │
105 │ @down interactive="" profile="" *$services="": _require-docker _require-compose
    │  ^^^^

Strictness: should malformed module payloads fail fast rather than being skipped?

Good question. I think you are right, if the dump is malformed we should fail fast.


Dependency semantics: should dependency APIs return local names, qualified namepaths, or both?

Needs some thought - not sure what the right answer is here.


Naming consistency: PR description references all_modules, implementation uses module_namepaths - can we standardise wording.

Well spotted - I asked casey to implement a function to return the current module, he settled on module_path() as he considers namepath to be an internal name.

casey/just#3260

recipes() in pytest-just returns objects so I didn't want to use modules() as we are surfacing a list of string. I think it probably makes sense to follow just and have modules_paths()

What do you think?

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.

Module support

2 participants