Skip to content

fix(cli): replace union-with-None hints in CLI modules#272

Open
EnrikoMM wants to merge 1 commit intoteng-lin:mainfrom
EnrikoMM:fix/python39-cli-type-hints
Open

fix(cli): replace union-with-None hints in CLI modules#272
EnrikoMM wants to merge 1 commit intoteng-lin:mainfrom
EnrikoMM:fix/python39-cli-type-hints

Conversation

@EnrikoMM
Copy link
Copy Markdown

@EnrikoMM EnrikoMM commented Apr 12, 2026

Summary

  • replace X | None annotations in CLI modules with Optional[X]
  • update related annotations to Tuple[...] / Union[...] forms in the same paths
  • keep behavior unchanged while making type-hint syntax compatible with older Python interpreters

Files

  • src/notebooklm/cli/helpers.py
  • src/notebooklm/cli/download.py
  • src/notebooklm/cli/download_helpers.py
  • src/notebooklm/cli/skill.py
  • src/notebooklm/cli/generate.py

Co-Authored-By: Oz oz-agent@warp.dev

Summary by CodeRabbit

  • Refactor
    • Updated type annotations across CLI modules to use consistent typing conventions, ensuring better code maintainability without any changes to application functionality.

Use Optional/Tuple/Union typing forms in CLI helper modules to avoid runtime issues on older Python interpreters when evaluating annotations.

Co-Authored-By: Oz <oz-agent@warp.dev>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e8e0a195-28a2-4815-82ea-24f2fc45feb3

📥 Commits

Reviewing files that changed from the base of the PR and between a997718 and 9d82c5f.

📒 Files selected for processing (5)
  • src/notebooklm/cli/download.py
  • src/notebooklm/cli/download_helpers.py
  • src/notebooklm/cli/generate.py
  • src/notebooklm/cli/helpers.py
  • src/notebooklm/cli/skill.py

📝 Walkthrough

Walkthrough

Type annotations across CLI modules were systematically updated from Python 3.10-style union syntax (T | None) to traditional Optional[...] and Tuple[...] constructs, affecting function signatures and internal variable declarations across five files.

Changes

Cohort / File(s) Summary
Type Annotation Standardization
src/notebooklm/cli/download.py, src/notebooklm/cli/download_helpers.py, src/notebooklm/cli/generate.py, src/notebooklm/cli/helpers.py, src/notebooklm/cli/skill.py
Systematically replaced PEP-604 union syntax with Optional[...], Tuple[...], and Union[...] constructs across function parameters, return types, and variable annotations. Examples include converting `str

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 From pipes to Options, the rabbit does hop,
Type hints made consistent, the changes won't stop!
Optional paths and Tuples so neat,
Cleaner annotations, the syntax complete!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(cli): replace union-with-None hints in CLI modules' accurately and specifically describes the main change—replacing PEP 604-style union-with-None type annotations with Optional/Tuple/Union forms across CLI modules.
Docstring Coverage ✅ Passed Docstring coverage is 92.86% which is sufficient. The required threshold is 80.00%.

✏️ 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
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates type annotations across several CLI modules, replacing the Python 3.10+ union operator (|) with Optional and Union from the typing module. The review feedback suggests maintaining consistency with PEP 585 by using built-in lowercase generics like tuple instead of importing Tuple from the typing module.

from functools import partial
from pathlib import Path
from typing import Any, TypedDict
from typing import Any, Optional, Tuple, TypedDict
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Since the codebase uses lowercase generics like list, dict, and tuple elsewhere (e.g., dict[str, Any] on line 181), importing Tuple from typing is unnecessary for Python 3.9+ compatibility. It's better to stick to the lowercase tuple for consistency.

Suggested change
from typing import Any, Optional, Tuple, TypedDict
from typing import Any, Optional, TypedDict
References
  1. PEP 585: Support for the generic alias type in standard collections allows using lowercase types like 'tuple' instead of 'typing.Tuple' for type hints in Python 3.9+. (link)


# Helper for file conflict resolution
def _resolve_conflict(path: Path) -> tuple[Path | None, dict | None]:
def _resolve_conflict(path: Path) -> Tuple[Optional[Path], Optional[dict]]:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

For consistency with the rest of the codebase and other CLI modules in this PR (which use lowercase generics like list[str] and tuple[str, ...]), please use the lowercase tuple here instead of Tuple.

Suggested change
def _resolve_conflict(path: Path) -> Tuple[Optional[Path], Optional[dict]]:
def _resolve_conflict(path: Path) -> tuple[Optional[Path], Optional[dict]]:
References
  1. PEP 585: Support for the generic alias type in standard collections allows using lowercase types like 'tuple' instead of 'typing.Tuple' for type hints in Python 3.9+. (link)

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