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 1 commit into
masterfrom
workspace-typings
Open

tony wants to merge 1 commit into
masterfrom
workspace-typings

Conversation

@tony

@tony tony commented Jun 7, 2025 •

Copy link
Copy Markdown
Member

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

sourcery-ai Bot commented Jun 7, 2025 •

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

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
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
from tmuxp.types import WorkspaceConfig
def import_tmuxinator(workspace_dict: dict[str, t.Any]) -> WorkspaceConfig:
"""Return tmuxp workspace from a `tmuxinator`_ yaml workspace.
Returns
-------
WorkspaceConfig
A dictionary conforming to WorkspaceConfig structure.
"""
tmuxp_workspace: WorkspaceConfig = {} # Will conform to WorkspaceConfig at the end

@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
@tony
tony force-pushed the workspace-typings branch from a4a6010 to 17ca212 Compare April 26, 2026 10:32
@codecov

codecov Bot commented Apr 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.96970% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.74%. Comparing base (91ac851) to head (febcb35).
⚠️ Report is 61 commits behind head on master.

Files with missing lines Patch % Lines
src/tmuxp/workspace/importers.py 91.30% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #981      +/-   ##
==========================================
+ Coverage   82.56%   82.74%   +0.18%     
==========================================
  Files          31       31              
  Lines        2770     2811      +41     
  Branches      518      517       -1     
==========================================
+ Hits         2287     2326      +39     
- Misses        346      347       +1     
- Partials      137      138       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tony
tony force-pushed the workspace-typings branch from 17ca212 to 24a9c33 Compare June 6, 2026 12:51

This branch has not been deployed

No deployments
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