Skip to content

Conversation

@tony
Copy link
Member

@tony tony commented Jan 3, 2026

Summary

  • Replace t.Any with narrower types (object, int | str, etc.) throughout the codebase
  • Add TypedDict definitions for structured keyword argument patterns
  • Use function overloads for better type inference in temp helpers

Changes by area

Core library

  • exc.py: Narrow VariableUnpackingError.variable from t.Any to object
  • hooks.py: Narrow HookDict values from t.Any to int | str
  • pane.py, session.py, window.py, server.py: Narrow deprecated lookup methods (get, __getitem__, where, find_where) to use object instead of t.Any

Test utilities

  • pytest_plugin.py: Add SessionParams TypedDict for typed fixture parameters
  • test/temporary.py: Add TypedDicts (TempSessionParams, TempWindowParams, etc.) and use overloads for temp_session/temp_window functions

Tests

  • Narrow test fixture types throughout (ParameterSet, specific union types)
  • Tighten mock function signatures
  • Replace generic dict[str, t.Any] with specific TypedDicts

Test plan

  • All 872 tests pass
  • mypy passes with no issues
  • ruff linting clean

tony added 19 commits January 3, 2026 06:11
why: Improve hook typing specificity for show_hooks output.
what:
- Replace HookDict values from Any to int | str to match parsing logic
why: Narrow send/return types for temp_session and temp_window.
what:
- Use Generator[..., None, None] for contextmanager yields
why: Use specific LooseVersion operands in version comparison fixtures.
what:
- Narrow VersionCompareOp and fixture fields to str inputs
why: Align sparse-array test inputs with ExplodedComplexUntypedOptionsDict.
what:
- Replace Any with ExplodedComplexUntypedOptionsDict
- Instantiate SparseArray with matching str | int parameter
why: Replace Any in deprecated window method fixture types with concrete unions.
what:
- Narrow args/kwargs types and return ParameterSet list
why: Remove Any from test-only output type alias.
what:
- Replace OutputRaw value type with str
why: Replace Any in option fixture expected values with specific dict unions.
what:
- Set expected type to dict[str, str | list[str]]
why: Replace Any in hook test helper types with TypedDicts and ParameterSet.
what:
- Add SetHooksOperationArgs/SetHookFlagArgs for kwargs
- Use ParameterSet and MarkDecorator in helper annotations
why: Replace Any in option test helpers with concrete unions and ParameterSet.
what:
- Constrain OptionTestCase.test_value and conversion expectations
- Use ParameterSet/MarkDecorator in helper builders
why: Improve mock signature specificity without changing behavior.
what:
- Replace Any with object for tmux_cmd mock args/kwargs in common tests
- Narrow patched_cmd kwargs to str|int|None in session tests
why: Provide concrete, key-aware typing for session fixture overrides.
what:
- Add SessionParams TypedDict aligned with Server.new_session kwargs
- Use SessionParams in session_params and session fixture signatures
why: Expose precise, key-aware kwargs for temp helpers without restricting callers.
what:
- Add TypedDicts and overloads for temp_session/temp_window kwargs
- Wrap contextmanager generators to return ContextManager types explicitly
why: Replace Any with object-based aliases for broader but explicit typing.
what:
- Define FilterExpr/ExpectedResult aliases in QueryList tests
- Use list[object] and QueryList[object] in test_filter signature
why: Remove Any from temp helper kwargs while preserving flexible passthrough.
what:
- Split TempSession/TempWindow kwargs into forwarded TypedDicts
- Filter name keys before forwarding to avoid duplicate keywords
why: Use object for error payloads instead of Any to avoid implicit typing.
what:
- Update VariableUnpackingError variable parameter to object | None
why: Deprecated APIs still surface in docs; clearer types help readers.
what:
- Replace Any with object for get and __getitem__
- Use dict[str, object] for where and find_where parameters
why: Deprecated methods still appear in docs; more precise types aid usage.
what:
- Replace Any with object for get and __getitem__
- Use dict[str, object] for where and find_where parameters
why: Deprecated lookup helpers are still documented; tighter types are clearer.
what:
- Replace Any with object for get and __getitem__ defaults/returns
why: Deprecated API hints should be specific even if the runtime path is unused.
what:
- Replace Any with object in where and find_where parameter types
@codecov
Copy link

codecov bot commented Jan 3, 2026

Codecov Report

❌ Patch coverage is 72.04301% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.23%. Comparing base (849cbca) to head (24ee357).

Files with missing lines Patch % Lines
src/libtmux/pytest_plugin.py 0.00% 10 Missing ⚠️
src/libtmux/session.py 0.00% 4 Missing ⚠️
src/libtmux/window.py 0.00% 4 Missing ⚠️
src/libtmux/pane.py 0.00% 2 Missing ⚠️
src/libtmux/server.py 0.00% 2 Missing ⚠️
src/libtmux/test/temporary.py 97.10% 2 Missing ⚠️
src/libtmux/exc.py 0.00% 1 Missing ⚠️
src/libtmux/hooks.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #618      +/-   ##
==========================================
+ Coverage   45.39%   46.23%   +0.83%     
==========================================
  Files          22       22              
  Lines        2249     2308      +59     
  Branches      360      364       +4     
==========================================
+ Hits         1021     1067      +46     
- Misses       1082     1095      +13     
  Partials      146      146              

☔ View full report in Codecov by Sentry.
📢 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
Copy link
Member Author

tony commented Jan 3, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

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.

2 participants