fix(deps): align _count_package_files to use .apm/context/ (singular) dir#748
Conversation
sergio-sisternes-epam
left a comment
There was a problem hiding this comment.
Good catch on the contexts -> context typo in _count_package_files()! The core fix is correct and the test coverage is solid.
However, this PR bundles several unrelated changes that should be split:
- The context dir fix (the actual bug fix for #704) -- great, keep this and its test
- Formatting cleanup across
_utils.pyand_helpers.py(single->double quotes, line wrapping) -- should be a separate PR start.prompt.mdcreation in_create_minimal_apm_yml()andinit.pychanges -- these overlap with #649 which already addresses this exact feature. Merging both would create conflicts.
Could you please scope this down to just the _count_package_files() fix in _utils.py and its corresponding test? The formatting and init changes create unnecessary merge conflicts with other in-flight PRs.
The new test_deps_utils.py test file is welcome -- but please submit it without the init/helpers changes mixed in.
7d271e6 to
6ab396c
Compare
|
@sergio-sisternes-epam Thanks for the thorough review! Scoped the PR down to just the _count_package_files() fix and the test file — removed the formatting changes from _utils.py / _helpers.py and the init.py changes (noted the overlap with #649). Now it's a single commit touching only src/apm_cli/commands/deps/_utils.py (1-line change) and tests/unit/test_deps_utils.py. |
There was a problem hiding this comment.
Pull request overview
Fixes a mismatch in dependency package scanning so apm deps list correctly counts context files by using the canonical .apm/context/ (singular) directory, aligning it with the rest of the codebase and apm view.
Changes:
- Update
_count_package_files()to scan.apm/context/(singular) instead of.apm/contexts/. - Add/adjust unit tests covering
_utils.pyhelpers, including the corrected context directory expectation.
Show a summary per file
| File | Description |
|---|---|
src/apm_cli/commands/deps/_utils.py |
Aligns context directory scanning to the canonical .apm/context/ to fix incorrect context counts in deps output. |
tests/unit/test_deps_utils.py |
Adds comprehensive unit tests for deps utility helpers and pins the corrected context directory behavior. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 2
_count_package_files() scanned .apm/contexts/ (plural), which does not exist. The canonical directory is .apm/context/ (singular), consistent with _get_detailed_context_counts() in the same file and the discovery pattern in primitives/discovery.py. Result: apm deps list always reported 0 context files even for packages with many .context.md files in .apm/context/. apm view showed the correct count via _get_detailed_context_counts, making the two commands disagree. Verified: pytest tests/unit/ — 3907 passed on Python 3.13, Windows 11 Fixes microsoft#704
0770011 to
92428b1
Compare
|
Rebased onto the latest main and resolved the conflict with #682's merged test file. Two changes applied on top of main's test_deps_utils.py: 1.Removed unused tempfile and patch imports as suggested. Regarding the docs finding — the references to contexts/ (plural) in docs/ and packages/apm-guide/ are pre-existing and outside this PR's scope. Happy to open a follow-up PR to update those if that's the preferred approach. |
Changes added by @edenfunf
What
_count_package_files()insrc/apm_cli/commands/deps/_utils.pyscanned.apm/contexts/(plural) for context files, but the canonical directory is.apm/context/(singular). This causedapm deps listto always report 0 context files for every package, whileapm viewshowed the correct count — a silent, persistent inconsistency.Before:
After:
Why
.apm/context/(singular) is the established convention across the codebase:_get_detailed_context_counts()in the same file already maps correctly, with an explicit comment:primitives/discovery.pyuses"**/.apm/context/*.context.md"._count_package_files()was the only function using the wrong plural form, so it always traversed a directory that doesn't exist and returned 0.How
One-character change:
'contexts'→'context'in_count_package_files(), aligning it with_get_detailed_context_counts()atsrc/apm_cli/commands/deps/_utils.py:149.No public CLI interface is affected —
apm --helpoutput is unchanged.Tests
The test suite covers all public helpers in
_utils.pyacross 8 test classes, adapted from the structure proposed in #682. One test was corrected in the process:test_contexts_dir_countedin #682 created.apm/contexts/(plural) and expected a non-zero count, which validated the buggy behavior. This PR changes it to use.apm/context/(singular), so it now correctly documents and pins the fix.Fixes #704