types(workspace-imports) Example typings via `NotRequried` by tony · Pull Request #981 · tmux-python/tmuxp · GitHub
Skip to content

types(workspace-imports) Example typings via NotRequried#981

Open
tony wants to merge 3 commits intomasterfrom
workspace-typings
Open

types(workspace-imports) Example typings via NotRequried#981
tony wants to merge 3 commits intomasterfrom
workspace-typings

Conversation

@tony
Copy link
Copy Markdown
Member

@tony tony commented Jun 7, 2025

Summary by Sourcery

Add example typings for workspace imports by introducing detailed TypedDict schemas and updating importers to reference the new workspace configuration types

Enhancements:

  • Define comprehensive TypedDict schemas for shell commands, panes, windows, and workspace configuration using NotRequired for optional fields
  • Introduce union types for shell command and pane values to capture both simple and detailed configurations
  • Annotate importer functions to reference the WorkspaceConfig type under TYPE_CHECKING and update docstrings to indicate the returned dict conforms to WorkspaceConfig

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Jun 7, 2025

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey @tony - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread src/tmuxp/workspace/importers.py Outdated
Comment on lines +18 to +26
Returns
-------
dict
A dictionary conforming to WorkspaceConfig structure.
"""
tmuxp_workspace: dict[str, t.Any] = {}
tmuxp_workspace: dict[str, t.Any] = {} # Will conform to WorkspaceConfig at the end
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Annotate tmuxp_workspace with WorkspaceConfig type

Since WorkspaceConfig is already imported under TYPE_CHECKING, use it to annotate tmuxp_workspace and update the function's return type for better type safety.

Suggested change

@tony tony force-pushed the workspace-typings branch 2 times, most recently from 7466b20 to ea9a61f Compare June 7, 2025 12:44
@tony tony force-pushed the workspace-typings branch from ea9a61f to a4a6010 Compare June 14, 2025 15:42
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