Skip to content

feat: support template_dirs config settings#760

Merged
derks merged 2 commits into
mainfrom
feat/support-template-dirs-meta-override
May 8, 2026
Merged

feat: support template_dirs config settings#760
derks merged 2 commits into
mainfrom
feat/support-template-dirs-meta-override

Conversation

@derks
Copy link
Copy Markdown
Member

@derks derks commented Jun 10, 2025

Add support for App.Meta.template_dirs and configuration override.

Resolves Issue #746

Summary by CodeRabbit

  • New Features

    • App config can now override default template directories (accepts native list or comma-separated string; string form is parsed and normalized).
  • Documentation

    • Changelog entry added; contributor list updated; planning/state records updated.
  • Tests

    • New tests cover list/string parsing, empty-token handling, placeholder substitution, and precedence of configured template directories.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 10, 2025

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1d3682dd-5e11-461a-a7ed-2fc40c470a9b

📥 Commits

Reviewing files that changed from the base of the PR and between abc076c and 3167f38.

📒 Files selected for processing (7)
  • .planning/STATE.md
  • .planning/quick/260507-to4-rewrite-pr-760-template-dirs-config-over/260507-to4-PLAN.md
  • .planning/quick/260507-to4-rewrite-pr-760-template-dirs-config-over/260507-to4-SUMMARY.md
  • CHANGELOG.md
  • CONTRIBUTORS.md
  • cement/core/foundation.py
  • tests/core/test_foundation.py
✅ Files skipped from review due to trivial changes (3)
  • CONTRIBUTORS.md
  • .planning/quick/260507-to4-rewrite-pr-760-template-dirs-config-over/260507-to4-PLAN.md
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • cement/core/foundation.py
  • .planning/quick/260507-to4-rewrite-pr-760-template-dirs-config-over/260507-to4-SUMMARY.md

📝 Walkthrough

Walkthrough

App.Meta.template_dirs can now be overridden from app config; config-provided comma-separated strings are normalized to trimmed lists and synced to Meta. Five tests verify list override, string parsing (including dropping empty tokens), token substitution, and precedence. CHANGELOG, CONTRIBUTORS, and planning metadata were updated.

Changes

Template dirs override

Layer / File(s) Summary
Meta override
cement/core/foundation.py
Added template_dirs to App.Meta.core_meta_override and updated App.Meta.template_dirs docstring to document list or comma-separated string config support.
Config normalization
cement/core/foundation.py
_setup_config_handler() now parses template_dirs provided as comma-separated strings into trimmed lists, writes normalized list back to config, and syncs self._meta.template_dirs.
Tests
tests/core/test_foundation.py
Added tests: test_template_dirs_via_config, test_template_dirs_via_config_string, test_template_dirs_via_config_string_drops_empty_tokens, test_template_dirs_via_config_substitution, test_template_dirs_via_config_precedence covering list override, string parsing, empty-token dropping, placeholder expansion, and precedence ordering.
Changelog & Contributors
CHANGELOG.md, CONTRIBUTORS.md
CHANGELOG updated under 3.0.15 DEVELOPMENT to document the new [core.foundation] config override; CONTRIBUTORS added Tom Freudenberg.
Planning / Quick Task
.planning/STATE.md, .planning/quick/.../260507-to4-PLAN.md, .planning/quick/.../260507-to4-SUMMARY.md
Planning files updated to record the quick-task rewrite, plan, summary, and to mark the quick task completed in STATE.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant Config
    participant TemplateHandler

    User->>App: Start application
    App->>Config: Check for 'template_dirs' in config
    alt 'template_dirs' found in config
        Config-->>App: Return config 'template_dirs' (str or list)
        App->>App: Normalize (if str -> split/trim) and write back to config
        App->>App: Set self._meta.template_dirs from normalized list
    else Not found
        App->>App: Use Meta.template_dirs
    end
    App->>TemplateHandler: Setup with final template_dirs list
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

In the burrow of builds I did confide,
Paths once fixed now follow the config's tide.
Tests hop in chorus, tidy and spry,
Tom's name joins footprints as changes fly.
🐰🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: support template_dirs config settings' directly summarizes the main change: adding support for template_dirs configuration overrides via the core_meta_override mechanism.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/support-template-dirs-meta-override

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
cement/core/foundation.py (1)

525-535: Fix typo in comment.

There's a typo in the comment: "becuase" should be "because".

-            # reverse it becuase it will be reverse again (keep user preference)
+            # reverse it because it will be reversed again (keep user preference)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8b03817 and 0cf3873.

📒 Files selected for processing (4)
  • CHANGELOG.md (1 hunks)
  • CONTRIBUTORS.md (1 hunks)
  • cement/core/foundation.py (3 hunks)
  • tests/core/test_foundation.py (1 hunks)
🧰 Additional context used
🪛 Pylint (3.3.7)
cement/core/foundation.py

[error] 1554-1554: Instance of 'Meta' has no 'core_user_template_dirs' member

(E1101)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test
🔇 Additional comments (8)
cement/core/foundation.py (4)

500-500: LGTM: Adding template_dirs to core_meta_override list.

This correctly enables configuration override for the template_dirs meta attribute, consistent with other overridable meta options.


525-535: Excellent implementation of config override logic.

The logic correctly:

  • Checks for template_dirs in the config section
  • Handles both list and comma-separated string formats
  • Reverses the list to maintain user preference order
  • Follows established patterns from similar config overrides

544-553: LGTM: Config-aware template directory selection.

The conditional logic properly prioritizes config-provided template_dirs over meta-defined ones while maintaining the established directory precedence order.


1554-1554: The static analysis hint is a false positive.

The static analysis tool flagged core_user_template_dirs as missing, but this attribute is clearly defined in the Meta class at lines 723-726. This is a false positive and can be safely ignored.

🧰 Tools
🪛 Pylint (3.3.7)

[error] 1554-1554: Instance of 'Meta' has no 'core_user_template_dirs' member

(E1101)

tests/core/test_foundation.py (3)

782-795: Excellent test coverage for config override functionality.

This test properly verifies that:

  • Config template_dirs override meta template_dirs
  • Original meta paths are excluded when config overrides exist
  • Both list formats work correctly

The test design is clean and assertions are appropriate.


797-809: Good test for string format conversion.

This test correctly validates the comma-separated string parsing functionality, including handling of whitespace around commas. The test design matches the expected behavior from the implementation.


811-823: Thorough test for template_dir and template_dirs interaction.

This test ensures that both singular template_dir and plural template_dirs settings work together correctly, which is important for backward compatibility and flexibility.

CONTRIBUTORS.md (1)

26-26: LGTM: Welcome new contributor!

Appropriate addition of the new contributor following the established format.

Comment thread CHANGELOG.md Outdated
@derks
Copy link
Copy Markdown
Member Author

derks commented Jun 10, 2025

@TomFreudenberg this PR is ready for review if you are interested to test it. I believe it solves your requests in Issue #746 - I'm not going to merge it just yet, I need to review some things. Particularly, on whether the config template_dirs should append to App.Meta.template_dirs, or overwrite it. Currently (in this PR) it is overwriting it but I'm not 100% on that yet. Happy to hear your thoughts as a user/consumer.

This also adds you to the CONTRIBUTORS.md file that you mentioned in a previous PR.

Thank you for your patience.

@TomFreudenberg
Copy link
Copy Markdown
Contributor

TomFreudenberg commented Oct 30, 2025

Dear @derks

sorry for being very late on your feedback and your effort. I had some private issues and it took a while for me to continue work. I will come up to you with feedback soon.

Kindly regards
Tom

@derks
Copy link
Copy Markdown
Member Author

derks commented Oct 30, 2025

@TomFreudenberg good to hear from you, and sorry to hear the unfortunate news. I have fallen behind in active dev, so this is a good reminder for me as well. No rush, its always good to have your feedback on Cement.

derks added a commit that referenced this pull request May 8, 2026
Quick task scaffolding for the PR #760 rewrite — PLAN.md captures the
scope decisions (use core_meta_override, leave _setup_template_handler
untouched, replace-not-extend semantics), and SUMMARY.md records the
final state including verification results and the pre-push local-only
status pending user review.
@derks derks force-pushed the feat/support-template-dirs-meta-override branch from 0cf3873 to 4d61a86 Compare May 8, 2026 03:03
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cement/core/foundation.py`:
- Around line 1466-1475: The normalization block for template_dirs uses
self._meta.config_section in the guard but calls self.config.get and
self.config.set with label, causing normalization to miss the actual config
section when label != self._meta.config_section; update the calls to use
self._meta.config_section (or consistently use label throughout) so the get and
set operate on the same section checked by the guard — specifically adjust the
usages of self.config.get(label, 'template_dirs') and self.config.set(label,
'template_dirs', dir_list') to reference self._meta.config_section (and ensure
_meta.template_dirs is updated accordingly).
- Around line 1470-1472: When `dirs` is a comma-separated string, the current
split keeps empty tokens (e.g. trailing commas); in the block handling `if
type(dirs) is str:` (variable names `dirs` and `dir_list` in
cement.core.foundation.py) change the construction of `dir_list` to strip each
token and drop empty/falsy results (i.e., build `dir_list` from tokens where
`token.strip()` is non-empty) so accidental empty path entries are not included
in template path resolution.

In `@tests/core/test_foundation.py`:
- Around line 844-847: The Meta class currently uses mutable list literals for
core_system_template_dirs, core_user_template_dirs, and template_dirs which Ruff
flags; replace those list literals with immutable tuples (e.g., ('/sys/dir',))
or set them to None and initialize immutable sequences at runtime so they are
not mutable class defaults; update the attributes core_system_template_dirs,
core_user_template_dirs, and template_dirs accordingly (leave template_dir
as-is) to satisfy RUF012 and re-run the ruff/comply checks.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7725a4f3-2a10-49a3-a9f9-ac715597b2c4

📥 Commits

Reviewing files that changed from the base of the PR and between 0cf3873 and 4d61a86.

📒 Files selected for processing (7)
  • .planning/STATE.md
  • .planning/quick/260507-to4-rewrite-pr-760-template-dirs-config-over/260507-to4-PLAN.md
  • .planning/quick/260507-to4-rewrite-pr-760-template-dirs-config-over/260507-to4-SUMMARY.md
  • CHANGELOG.md
  • CONTRIBUTORS.md
  • cement/core/foundation.py
  • tests/core/test_foundation.py
✅ Files skipped from review due to trivial changes (3)
  • CONTRIBUTORS.md
  • .planning/quick/260507-to4-rewrite-pr-760-template-dirs-config-over/260507-to4-PLAN.md
  • .planning/STATE.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md

Comment thread cement/core/foundation.py
Comment thread cement/core/foundation.py
Comment on lines +844 to +847
core_system_template_dirs = ['/sys/dir']
core_user_template_dirs = ['/usr/dir']
template_dir = '/single/dir'
template_dirs = ['/meta/dir/should/be/replaced']
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Avoid mutable list defaults in nested Meta class attributes (RUF012).

core_system_template_dirs, core_user_template_dirs, and template_dirs are list literals on class attrs. Ruff flags this pattern and it can break compliance gates.

Suggested fix
-            core_system_template_dirs = ['/sys/dir']
-            core_user_template_dirs = ['/usr/dir']
+            core_system_template_dirs = ('/sys/dir',)
+            core_user_template_dirs = ('/usr/dir',)
             template_dir = '/single/dir'
-            template_dirs = ['/meta/dir/should/be/replaced']
+            template_dirs = ('/meta/dir/should/be/replaced',)

As per coding guidelines, "**/*.py: Run ruff linting via make comply-ruff and auto-fix issues with make comply-ruff-fix" and "Maintain 100% PEP8 compliance via ruff ... enforced as absolute quality gates."

🧰 Tools
🪛 Ruff (0.15.12)

[warning] 844-844: Mutable default value for class attribute

(RUF012)


[warning] 845-845: Mutable default value for class attribute

(RUF012)


[warning] 847-847: Mutable default value for class attribute

(RUF012)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/core/test_foundation.py` around lines 844 - 847, The Meta class
currently uses mutable list literals for core_system_template_dirs,
core_user_template_dirs, and template_dirs which Ruff flags; replace those list
literals with immutable tuples (e.g., ('/sys/dir',)) or set them to None and
initialize immutable sequences at runtime so they are not mutable class
defaults; update the attributes core_system_template_dirs,
core_user_template_dirs, and template_dirs accordingly (leave template_dir
as-is) to satisfy RUF012 and re-run the ruff/comply checks.

derks added a commit that referenced this pull request May 8, 2026
Quick task scaffolding for the PR #760 rewrite — PLAN.md captures the
scope decisions (use core_meta_override, leave _setup_template_handler
untouched, replace-not-extend semantics), and SUMMARY.md records the
final state including verification results and the pre-push local-only
status pending user review.
@derks derks force-pushed the feat/support-template-dirs-meta-override branch from 4d61a86 to 0df5e6a Compare May 8, 2026 03:07
derks added a commit that referenced this pull request May 8, 2026
Quick task scaffolding for the PR #760 rewrite — PLAN.md captures the
scope decisions (use core_meta_override, leave _setup_template_handler
untouched, replace-not-extend semantics), and SUMMARY.md records the
final state including verification results and the pre-push local-only
status pending user review.
@derks derks force-pushed the feat/support-template-dirs-meta-override branch from 0df5e6a to abc076c Compare May 8, 2026 03:10
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (3)
cement/core/foundation.py (2)

1474-1474: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Empty path tokens produced by trailing/double commas still not filtered.

'a,,b,'.split(',') produces ['a', '', 'b', '']; after .strip() the empty strings remain and become invalid entries in template path resolution.

🐛 Proposed fix
-                dir_list = [x.strip() for x in dirs.split(',')]
+                dir_list = [x.strip() for x in dirs.split(',') if x.strip()]
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cement/core/foundation.py` at line 1474, The current creation of dir_list
from dirs leaves empty tokens when there are trailing or consecutive commas;
update the comprehension that builds dir_list (the one using dirs.split(',')) to
discard empty/whitespace-only entries after stripping — i.e., filter tokens by
checking x.strip() so only non-empty paths remain; adjust any downstream
assumptions if necessary that rely on dir_list containing only valid, non-empty
path strings.

1469-1481: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

label vs self._meta.config_section mismatch still unresolved.

Line 1469 guards on self._meta.config_section, but lines 1470 and 1477 pass label (self._meta.label) to config.get/config.set. When a caller explicitly sets a config_section that differs from the app label, the guard checks the correct section but the read/write targets the wrong one — leaving _meta.template_dirs holding the raw string and the active section uncorrected.

🐛 Proposed fix
-        if 'template_dirs' in self.config.keys(self._meta.config_section):
-            dirs = self.config.get(label, 'template_dirs')
+        section = self._meta.config_section
+        if 'template_dirs' in self.config.keys(section):
+            dirs = self.config.get(section, 'template_dirs')

             # convert a comma-separated string to a list
             if type(dirs) is str:
                 dir_list = [x.strip() for x in dirs.split(',')]

                 # set the new template_dirs value in the config
-                self.config.set(label, 'template_dirs', dir_list)
+                self.config.set(section, 'template_dirs', dir_list)

                 # also update _meta.template_dirs which the override loop
                 # above set to the raw string
                 self._meta.template_dirs = dir_list
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cement/core/foundation.py` around lines 1469 - 1481, The guard checks
self._meta.config_section but the code incorrectly uses label when calling
self.config.get and self.config.set and when updating self._meta.template_dirs;
change those calls to use the same section (self._meta.config_section) so
read/write targets the guarded section and then update self._meta.template_dirs
from the normalized list returned by self.config.get(self._meta.config_section,
'template_dirs') after converting comma strings to list.
tests/core/test_foundation.py (1)

844-847: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

RUF012: mutable list defaults in nested Meta class still unresolved.

core_system_template_dirs, core_user_template_dirs, and template_dirs are mutable list literals as class attributes. Ruff flags all three, and the linter is an absolute quality gate per the coding guidelines.

🔧 Proposed fix
-            core_system_template_dirs = ['/sys/dir']
-            core_user_template_dirs = ['/usr/dir']
             template_dir = '/single/dir'
-            template_dirs = ['/meta/dir/should/be/replaced']
+            core_system_template_dirs = ('/sys/dir',)
+            core_user_template_dirs = ('/usr/dir',)
+            template_dirs = ('/meta/dir/should/be/replaced',)

As per coding guidelines, **/*.py: Run ruff linting via make comply-ruff ... Maintain 100% PEP8 compliance via ruff ... enforced as absolute quality gates.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/core/test_foundation.py` around lines 844 - 847, The nested Meta class
uses mutable list literals for core_system_template_dirs,
core_user_template_dirs, and template_dirs which triggers RUF012; replace those
list literals with immutable tuples (e.g., ('/sys/dir',), ('/usr/dir',),
('/meta/dir/should/be/replaced',)) or set them to None and initialize immutably
elsewhere, and update any test assertions that expect list types if needed; the
attributes to change are core_system_template_dirs, core_user_template_dirs, and
template_dirs in the Meta class (leave template_dir as-is).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@cement/core/foundation.py`:
- Line 1474: The current creation of dir_list from dirs leaves empty tokens when
there are trailing or consecutive commas; update the comprehension that builds
dir_list (the one using dirs.split(',')) to discard empty/whitespace-only
entries after stripping — i.e., filter tokens by checking x.strip() so only
non-empty paths remain; adjust any downstream assumptions if necessary that rely
on dir_list containing only valid, non-empty path strings.
- Around line 1469-1481: The guard checks self._meta.config_section but the code
incorrectly uses label when calling self.config.get and self.config.set and when
updating self._meta.template_dirs; change those calls to use the same section
(self._meta.config_section) so read/write targets the guarded section and then
update self._meta.template_dirs from the normalized list returned by
self.config.get(self._meta.config_section, 'template_dirs') after converting
comma strings to list.

In `@tests/core/test_foundation.py`:
- Around line 844-847: The nested Meta class uses mutable list literals for
core_system_template_dirs, core_user_template_dirs, and template_dirs which
triggers RUF012; replace those list literals with immutable tuples (e.g.,
('/sys/dir',), ('/usr/dir',), ('/meta/dir/should/be/replaced',)) or set them to
None and initialize immutably elsewhere, and update any test assertions that
expect list types if needed; the attributes to change are
core_system_template_dirs, core_user_template_dirs, and template_dirs in the
Meta class (leave template_dir as-is).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bfa1d94b-031e-4789-b51b-75f5338a9b3d

📥 Commits

Reviewing files that changed from the base of the PR and between 4d61a86 and 0df5e6a.

📒 Files selected for processing (7)
  • .planning/STATE.md
  • .planning/quick/260507-to4-rewrite-pr-760-template-dirs-config-over/260507-to4-PLAN.md
  • .planning/quick/260507-to4-rewrite-pr-760-template-dirs-config-over/260507-to4-SUMMARY.md
  • CHANGELOG.md
  • CONTRIBUTORS.md
  • cement/core/foundation.py
  • tests/core/test_foundation.py
✅ Files skipped from review due to trivial changes (4)
  • CONTRIBUTORS.md
  • CHANGELOG.md
  • .planning/quick/260507-to4-rewrite-pr-760-template-dirs-config-over/260507-to4-PLAN.md
  • .planning/quick/260507-to4-rewrite-pr-760-template-dirs-config-over/260507-to4-SUMMARY.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • .planning/STATE.md

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
tests/core/test_foundation.py (1)

859-864: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Mutable list defaults in Meta still violate RUF012 (quality gate).

Lines 861, 862, and 864 use list literals as class-attribute defaults in the nested Meta class. Ruff's RUF012 rule flags all three, which blocks the make comply-ruff quality gate.

Replace with immutable tuples (the iteration in _setup_template_handler accepts any sequence):

🔧 Proposed fix
     class ThisTestApp(TestApp):
         class Meta:
-            core_system_template_dirs = ['/sys/dir']
-            core_user_template_dirs = ['/usr/dir']
+            core_system_template_dirs = ('/sys/dir',)
+            core_user_template_dirs = ('/usr/dir',)
             template_dir = '/single/dir'
-            template_dirs = ['/meta/dir/should/be/replaced']
+            template_dirs = ('/meta/dir/should/be/replaced',)

As per coding guidelines, "**/*.py: Run ruff linting via make comply-ruff" and "Maintain 100% PEP8 compliance via ruff … enforced as absolute quality gates."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/core/test_foundation.py` around lines 859 - 864, ThisTestApp.Meta
currently uses mutable list literals for core_system_template_dirs,
core_user_template_dirs, and template_dirs which triggers Ruff RUF012; change
those class-attribute defaults to immutable tuples (e.g. ('/sys/dir',) etc.) so
the nested Meta uses tuples instead of lists—_setup_template_handler accepts any
sequence so behavior is preserved; update the attributes
core_system_template_dirs, core_user_template_dirs, and template_dirs in the
Meta class accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@tests/core/test_foundation.py`:
- Around line 859-864: ThisTestApp.Meta currently uses mutable list literals for
core_system_template_dirs, core_user_template_dirs, and template_dirs which
triggers Ruff RUF012; change those class-attribute defaults to immutable tuples
(e.g. ('/sys/dir',) etc.) so the nested Meta uses tuples instead of
lists—_setup_template_handler accepts any sequence so behavior is preserved;
update the attributes core_system_template_dirs, core_user_template_dirs, and
template_dirs in the Meta class accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f21830cf-baaf-4fb9-9597-99512053e187

📥 Commits

Reviewing files that changed from the base of the PR and between 0df5e6a and abc076c.

📒 Files selected for processing (7)
  • .planning/STATE.md
  • .planning/quick/260507-to4-rewrite-pr-760-template-dirs-config-over/260507-to4-PLAN.md
  • .planning/quick/260507-to4-rewrite-pr-760-template-dirs-config-over/260507-to4-SUMMARY.md
  • CHANGELOG.md
  • CONTRIBUTORS.md
  • cement/core/foundation.py
  • tests/core/test_foundation.py
✅ Files skipped from review due to trivial changes (3)
  • CONTRIBUTORS.md
  • CHANGELOG.md
  • .planning/quick/260507-to4-rewrite-pr-760-template-dirs-config-over/260507-to4-PLAN.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • .planning/STATE.md
  • cement/core/foundation.py
  • .planning/quick/260507-to4-rewrite-pr-760-template-dirs-config-over/260507-to4-SUMMARY.md

derks added 2 commits May 7, 2026 22:13
Add 'template_dirs' to Meta.core_meta_override so config sections can
replace App.Meta.template_dirs at setup time, mirroring how 'template_dir'
(singular), 'plugin_dir', and the other handlers already work.

Config values may be a native list (under config handlers with native
list support, e.g. ext_yaml or ext_json) or a comma-separated string
(required for the default ext_configparser / INI handler, since INI has
no native list syntax). The string form is split + whitespace-trimmed
via a parallel block to the existing 'extensions' handling, immediately
after the generic core_meta_override loop. Empty tokens (trailing or
repeated commas) are dropped — strip handles intra-token whitespace,
the empty filter handles missing tokens, both are required to avoid
landing '' as a resolved path.

The get/set in this block consistently use self._meta.config_section
(the same section the guard checks), so the normalization works
correctly when an app has explicitly customized Meta.config_section to
a value other than Meta.label. _setup_template_handler is left
untouched, so config-supplied dirs go through the same {label} /
{home_dir} substitution and dedup checks as Meta-supplied dirs and sit
in the same precedence slot:

  core_user_template_dirs > template_dir > template_dirs > core_system_template_dirs

Resolves #746.
Quick task scaffolding for the PR #760 rewrite — PLAN.md captures the
scope decisions (use core_meta_override, leave _setup_template_handler
untouched, replace-not-extend semantics), and SUMMARY.md records the
final state including verification results and the pre-push local-only
status pending user review.
@derks derks force-pushed the feat/support-template-dirs-meta-override branch from abc076c to 3167f38 Compare May 8, 2026 03:13
@derks derks merged commit a667f23 into main May 8, 2026
14 checks passed
derks added a commit that referenced this pull request May 8, 2026
Track the parallel fix for the extensions config-override block in
core.foundation — same guard-vs-get/set divergence that PR #760 fixed
for template_dirs, but pre-existing in the extensions block. Scoped
out of #760 to keep that PR minimal; pickup after #760 merges.
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.

2 participants