feat: add custom theme directory support with typst_themes_path config#72
feat: add custom theme directory support with typst_themes_path config#72illilillillili wants to merge 3 commits into
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe PR introduces a Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/atsphinx/typst/theming.py (1)
155-155: ⚡ Quick winAvoid mutable default in
load_themesignature.Use
Noneand initialize inside the function to avoid shared default state across calls.Suggested patch
-def load_theme(name: str, typst_themes_path: list[Path] = []) -> Theme: +def load_theme(name: str, typst_themes_path: list[Path] | None = None) -> Theme: @@ + if typst_themes_path is None: + typst_themes_path = []🤖 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 `@src/atsphinx/typst/theming.py` at line 155, The load_theme function has a mutable default argument (empty list) for the typst_themes_path parameter, which can cause unexpected shared state across multiple function calls. Replace the empty list default with None, then add initialization logic at the beginning of the function body to check if typst_themes_path is None and set it to an empty list if so. This ensures each function call gets its own fresh list instance.Source: Linters/SAST tools
🤖 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 `@src/atsphinx/typst/config.py`:
- Around line 78-81: The code currently treats relative Path objects and string
paths inconsistently when building typst_themes_path. A relative Path object
like Path("_themes") stays relative and is appended directly, while a string
"_themes" is normalized to app.confdir / "_themes". To fix this, modify the
isinstance(p, Path) branch to check if the Path p is relative using the
is_absolute() method, and if it is relative, append app.confdir / p instead of
just p, matching the behavior of the string case.
---
Nitpick comments:
In `@src/atsphinx/typst/theming.py`:
- Line 155: The load_theme function has a mutable default argument (empty list)
for the typst_themes_path parameter, which can cause unexpected shared state
across multiple function calls. Replace the empty list default with None, then
add initialization logic at the beginning of the function body to check if
typst_themes_path is None and set it to an empty list if so. This ensures each
function call gets its own fresh list instance.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4a510e9d-beb2-4221-b512-a1b5b4aa8e24
📒 Files selected for processing (3)
src/atsphinx/typst/builders.pysrc/atsphinx/typst/config.pysrc/atsphinx/typst/theming.py
How to use
and then have
_themes/my_theme/theme.tomlavailable (seesrc/atsphinx/typst/themes/manualfor reference)Summary by CodeRabbit