8000 types: Add `StrPath` typing, fix `new_session` by tony · Pull Request #597 · tmux-python/libtmux · GitHub
[go: up one dir, main page]

Skip to content

types: Add StrPath typing, fix new_session #597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 26, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
types: Add StrPath
  • Loading branch information
tony committed May 26, 2025
commit 2f11a06adc19962d48cc446468df146bb66fdb51
19 changes: 19 additions & 0 deletions src/libtmux/_internal/types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""Internal type annotations.
Copy link
8000

Choose a reason for hiding this comment

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

issue: Doc mentions StrOrBytesPath but alias is not defined

Please define the StrOrBytesPath alias or remove its mention from the docstring to prevent confusion.


Notes
-----
:class:`StrPath` and :class:`StrOrBytesPath` is based on `typeshed's`_.

.. _typeshed's: https://github.com/python/typeshed/blob/5ff32f3/stdlib/_typeshed/__init__.pyi#L176-L179
""" # E501

from __future__ import annotations

import typing as t

if t.TYPE_CHECKING:
from os import PathLike

Comment on lines +12 to +16
Copy link

Choose a reason for hiding this comment

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

suggestion: TypeAlias used outside TYPE_CHECKING import block

Since StrPath: TypeAlias is at the module level, ensure TypeAlias is available at runtime by importing it outside the TYPE_CHECKING block or move the alias declaration inside the block for clarity.

Suggested change
import typing as t
if t.TYPE_CHECKING:
from os import PathLike
import typing as t
from typing import TypeAlias
if t.TYPE_CHECKING:
from os import PathLike

54F0

from typing_extensions import TypeAlias

StrPath: TypeAlias = "str | PathLike[str]"
0