-
Notifications
You must be signed in to change notification settings - Fork 111
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,19 @@ | ||||||||||||||||||||||
"""Internal type annotations. | ||||||||||||||||||||||
|
||||||||||||||||||||||
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Since
Suggested change
|
||||||||||||||||||||||
from typing_extensions import TypeAlias | ||||||||||||||||||||||
|
||||||||||||||||||||||
StrPath: TypeAlias = "str | PathLike[str]" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ | |
import sys | ||
import types | ||
|
||
from libtmux._internal.types import StrPath | ||
from libtmux.common import tmux_cmd | ||
|
||
if sys.version_info >= (3, 11): | ||
|
@@ -587,7 +588,7 @@ def new_window( | |
self, | ||
window_name: str | None = None, | ||
*, | ||
start_directory: str | None = None, | ||
start_directory: StrPath | None = None, | ||
attach: bool = False, | ||
window_index: str = "", | ||
window_shell: str | None = None, | ||
|
@@ -677,7 +678,8 @@ def new_window( | |
|
||
window_args += ("-P",) | ||
|
||
if start_directory is not None: | ||
# Catch empty string and default (`None`) | ||
if start_directory and isinstance(start_directory, str): | ||
# as of 2014-02-08 tmux 1.9-dev doesn't expand ~ in new-window -c. | ||
start_directory = pathlib.Path(start_directory).expanduser() | ||
window_args += (f"-c{start_directory}",) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (bug_risk): Unquoted directory argument may break on spaces Passing the directory as an unquoted string may fail if the path contains spaces. Use separate arguments for the flag and value, or ensure proper quoting. |
||
|
There was a problem hiding this comment.
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 definedPlease define the
StrOrBytesPath
alias or remove its mention from the docstring to prevent confusion.