Skip to content

chore: add missing type hints (15 files)#64

Open
mangodxd wants to merge 1 commit intobmad-code-org:mainfrom
mangodxd:cleanup/fix-py-issues-034668ee
Open

chore: add missing type hints (15 files)#64
mangodxd wants to merge 1 commit intobmad-code-org:mainfrom
mangodxd:cleanup/fix-py-issues-034668ee

Conversation

@mangodxd
Copy link
Copy Markdown

@mangodxd mangodxd commented Apr 5, 2026

Hello,

I noticed a few areas where the code could be made a bit more robust and readable. This PR focuses on minor housekeeping tasks and does not change any of the existing runtime logic:

Type hint additions

  • cleanup-legacy.py: added type hints to 1 function(s)
  • cleanup-legacy.py: added type hints to 1 function(s)
  • generate_excalidraw.py: added type hints to 10 function(s)
  • merge-config.py: added type hints to 1 function(s)
  • merge-config.py: added type hints to 1 function(s)
  • merge-config.py: added type hints to 1 function(s)
  • merge-config.py: added type hints to 1 function(s)
  • merge-help-csv.py: added type hints to 1 function(s)
  • merge-help-csv.py: added type hints to 1 function(s)
  • merge-help-csv.py: added type hints to 1 function(s)
  • merge-help-csv.py: added type hints to 1 function(s)
  • recall_metrics.py: added type hints to 1 function(s)
  • seed_tracker.py: added type hints to 1 function(s)
  • symbol_stats.py: added type hints to 1 function(s)
  • validate_excalidraw.py: added type hints to 2 function(s)

I have added basic type annotations based on variable names and default values. This should make the code easier to work with in modern IDEs without changing any of the actual logic.

Examples of changes

Example change in cleanup-legacy.py:

-def main():
+def main() -> None:

Example change in cleanup-legacy.py:

-def main():
+def main() -> None:

Safety and verification

  • I verified these changes using ast.parse() to ensure no syntax errors were introduced.
  • Files using dynamic patterns like eval() or globals() were automatically skipped.
  • I did not modify any __init__.py files.

Let me know if you would like me to change anything here.

Summary by CodeRabbit

  • Chores
    • Added comprehensive Python type annotations to entry-point and helper functions across utility scripts
    • Enhanced code clarity and type safety with explicit type declarations in configuration, metrics, and visualization utilities
    • Improved overall code quality for better developer experience without affecting runtime behavior

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 5, 2026

Walkthrough

Type annotations are added to Python script entry points and helper functions across multiple template and sample directories. All main() functions are annotated with -> None return type. The generate_excalidraw.py file receives comprehensive type annotations on helper functions including parameters and return types. No runtime behavior changes.

Changes

Cohort / File(s) Summary
Dream Weaver Agent Scripts
samples/bmad-agent-dream-weaver/scripts/merge-config.py, merge-help-csv.py, recall_metrics.py, seed_tracker.py, symbol_stats.py
Updated main() function signatures to main() -> None.
Excalidraw Scripts
samples/bmad-excalidraw/scripts/generate_excalidraw.py
Added comprehensive type annotations to helper functions (generate_id, make_base_element, make_shape, make_text, make_arrow, make_frame, layout_grid, layout_linear, layout_radial) including parameter types and return types.
Excalidraw Validation
samples/bmad-excalidraw/scripts/validate_excalidraw.py
Added type annotations to validate(file_path: str) and updated main() to main() -> None.
BMB Setup Scripts
skills/bmad-bmb-setup/scripts/cleanup-legacy.py, merge-config.py, merge-help-csv.py
Updated main() function signatures to main() -> None.
Module Builder Setup Skill Template
skills/bmad-module-builder/assets/setup-skill-template/scripts/cleanup-legacy.py, merge-config.py, merge-help-csv.py
Updated main() function signatures to main() -> None.
Module Builder Standalone Template
skills/bmad-module-builder/assets/standalone-module-template/merge-config.py, merge-help-csv.py
Updated main() function signatures to main() -> None.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Poem

🐰 Type hints bloom like morning clover,
Functions whisper what they'll return—
None declared, our work's all over,
Scripts now dance with types to learn! 🌱✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 67.74% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding type hints across 15 files. It is concise, specific, and directly reflects the primary objective of the PR.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

🧹 Nitpick comments (6)
samples/bmad-excalidraw/scripts/validate_excalidraw.py (1)

34-34: Consider adding return type annotation.

The parameter type annotation is good. You could complete the signature by adding the return type -> dict (based on the _build_result return at line 214).

📝 Proposed enhancement
-def validate(file_path: str):
+def validate(file_path: str) -> dict:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@samples/bmad-excalidraw/scripts/validate_excalidraw.py` at line 34, The
validate function currently has a parameter type but no return type; update the
signature of validate(file_path: str) to include the return type -> dict to
reflect that it returns the result built by _build_result; locate the validate
function and the _build_result call to ensure the annotation matches the actual
returned structure.
samples/bmad-excalidraw/scripts/generate_excalidraw.py (5)

174-175: PEP 484 violation: Use explicit T | None for optional parameters.

Multiple parameters with None defaults should use explicit optional syntax: start_id: int=None, end_id: int=None, and label: str=None should be start_id: int | None = None, end_id: int | None = None, and label: str | None = None.

♻️ Proposed fix for PEP 484 compliance
-def make_arrow(x1, y1, x2, y2, start_id: int=None, end_id: int=None, label: str=None,
-               style: str="arrow", start_shape=None, end_shape=None):
+def make_arrow(x1, y1, x2, y2, start_id: int | None = None, end_id: int | None = None, label: str | None = None,
+               style: str="arrow", start_shape=None, end_shape=None):
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@samples/bmad-excalidraw/scripts/generate_excalidraw.py` around lines 174 -
175, The function signature for make_arrow uses bare types with None defaults
which violates PEP 484; update the annotations to use explicit optional union
syntax for parameters with None defaults by changing start_id: int=None to
start_id: int | None = None, end_id: int=None to end_id: int | None = None, and
label: str=None to label: str | None = None (leave other params unchanged) so
type checkers correctly recognize optional types.

266-266: Consider adding return type annotation.

The function returns a position dictionary. Adding -> dict would complete the type signature (matching layout_linear and layout_radial at lines 304 and 373).

📝 Proposed enhancement
-def layout_grid(elements: list, direction: str="LR", start_x: int=100, start_y: int=100):
+def layout_grid(elements: list, direction: str="LR", start_x: int=100, start_y: int=100) -> dict:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@samples/bmad-excalidraw/scripts/generate_excalidraw.py` at line 266, The
function layout_grid lacks an explicit return type annotation; add "-> dict" to
its signature so the type signature matches layout_linear and layout_radial and
clearly indicates it returns a position dictionary. Update the def
layout_grid(elements: list, direction: str="LR", start_x: int=100, start_y:
int=100) declaration to include the return type annotation, leaving the
implementation unchanged.

145-145: PEP 484 violation: Use explicit T | None for optional parameter.

The parameter container_id: int=None should be container_id: int | None = None per PEP 484.

♻️ Proposed fix for PEP 484 compliance
-def make_text(x, y, text: str, container_id: int=None, width: int=200, height: int=80, font_size: int=20):
+def make_text(x, y, text: str, container_id: int | None = None, width: int=200, height: int=80, font_size: int=20):
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@samples/bmad-excalidraw/scripts/generate_excalidraw.py` at line 145, The
function signature for make_text uses the legacy optional annotation
container_id: int=None; update it to use the PEP 484 union-with-None form by
changing the parameter annotation to container_id: int | None = None (so the
function declaration in make_text reflects container_id as an explicit optional
type); ensure any other optional parameters follow the same pattern if present.

71-71: Consider adding return type annotation.

The function returns a string (generated ID). Adding -> str would complete the type signature.

📝 Proposed enhancement
-def generate_id(length: int=8):
+def generate_id(length: int=8) -> str:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@samples/bmad-excalidraw/scripts/generate_excalidraw.py` at line 71, The
function generate_id currently has a typed parameter but lacks a return type;
update its signature to include the return type annotation (-> str) so it reads
like generate_id(length: int = 8) -> str to clearly indicate the function
returns a string ID and complete the type signature.

123-123: PEP 484 violation: Use explicit T | None for optional parameters.

Per PEP 484, parameters with None defaults should use explicit optional type syntax. The parameters width: int=None and height: int=None should be width: int | None = None and height: int | None = None.

♻️ Proposed fix for PEP 484 compliance
-def make_shape(elem_type, x, y, label: str, width: int=None, height: int=None, bg_color=None) -> tuple:
+def make_shape(elem_type, x, y, label: str, width: int | None = None, height: int | None = None, bg_color=None) -> tuple:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@samples/bmad-excalidraw/scripts/generate_excalidraw.py` at line 123, The
function signature for make_shape uses bare defaults for optional parameters
width and height (width: int=None, height: int=None) which violates PEP 484;
update the annotations to use explicit optional union types (width: int | None =
None and height: int | None = None) in the make_shape definition so the typing
accurately reflects that these parameters may be None; keep the parameter order
and defaults unchanged and only adjust the type annotations.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@samples/bmad-excalidraw/scripts/generate_excalidraw.py`:
- Around line 174-175: The function signature for make_arrow uses bare types
with None defaults which violates PEP 484; update the annotations to use
explicit optional union syntax for parameters with None defaults by changing
start_id: int=None to start_id: int | None = None, end_id: int=None to end_id:
int | None = None, and label: str=None to label: str | None = None (leave other
params unchanged) so type checkers correctly recognize optional types.
- Line 266: The function layout_grid lacks an explicit return type annotation;
add "-> dict" to its signature so the type signature matches layout_linear and
layout_radial and clearly indicates it returns a position dictionary. Update the
def layout_grid(elements: list, direction: str="LR", start_x: int=100, start_y:
int=100) declaration to include the return type annotation, leaving the
implementation unchanged.
- Line 145: The function signature for make_text uses the legacy optional
annotation container_id: int=None; update it to use the PEP 484 union-with-None
form by changing the parameter annotation to container_id: int | None = None (so
the function declaration in make_text reflects container_id as an explicit
optional type); ensure any other optional parameters follow the same pattern if
present.
- Line 71: The function generate_id currently has a typed parameter but lacks a
return type; update its signature to include the return type annotation (-> str)
so it reads like generate_id(length: int = 8) -> str to clearly indicate the
function returns a string ID and complete the type signature.
- Line 123: The function signature for make_shape uses bare defaults for
optional parameters width and height (width: int=None, height: int=None) which
violates PEP 484; update the annotations to use explicit optional union types
(width: int | None = None and height: int | None = None) in the make_shape
definition so the typing accurately reflects that these parameters may be None;
keep the parameter order and defaults unchanged and only adjust the type
annotations.

In `@samples/bmad-excalidraw/scripts/validate_excalidraw.py`:
- Line 34: The validate function currently has a parameter type but no return
type; update the signature of validate(file_path: str) to include the return
type -> dict to reflect that it returns the result built by _build_result;
locate the validate function and the _build_result call to ensure the annotation
matches the actual returned structure.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b045e56f-9572-4167-a191-690d3ab90669

📥 Commits

Reviewing files that changed from the base of the PR and between 238277d and 6677940.

📒 Files selected for processing (15)
  • samples/bmad-agent-dream-weaver/scripts/merge-config.py
  • samples/bmad-agent-dream-weaver/scripts/merge-help-csv.py
  • samples/bmad-agent-dream-weaver/scripts/recall_metrics.py
  • samples/bmad-agent-dream-weaver/scripts/seed_tracker.py
  • samples/bmad-agent-dream-weaver/scripts/symbol_stats.py
  • samples/bmad-excalidraw/scripts/generate_excalidraw.py
  • samples/bmad-excalidraw/scripts/validate_excalidraw.py
  • skills/bmad-bmb-setup/scripts/cleanup-legacy.py
  • skills/bmad-bmb-setup/scripts/merge-config.py
  • skills/bmad-bmb-setup/scripts/merge-help-csv.py
  • skills/bmad-module-builder/assets/setup-skill-template/scripts/cleanup-legacy.py
  • skills/bmad-module-builder/assets/setup-skill-template/scripts/merge-config.py
  • skills/bmad-module-builder/assets/setup-skill-template/scripts/merge-help-csv.py
  • skills/bmad-module-builder/assets/standalone-module-template/merge-config.py
  • skills/bmad-module-builder/assets/standalone-module-template/merge-help-csv.py

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.

1 participant