Closed
Description
Server initialised without args have socket_name and socket_path as empty strings
>>> server = libtmux.Server()
>>> server
Server(socket_path=/tmp/tmux-1000/default)
>>> server.socket_path
>>> server.socket_name
>>> print(server)
Server(socket_path=/tmp/tmux-1000/default)
>>>
From the code it looks we dont initialise self.socket_path and self.socket_name, which we should, to default values.
Is this by design, or is it something that we should fix ? If its to be fixed, I can raise a PR for it.
Some relavant code snippets
Server class __init__
if socket_path is not None:
self.socket_path = socket_path
elif socket_name is not None:
self.socket_name = socket_name
tmux_tmpdir = pathlib.Path(os.getenv("TMUX_TMPDIR", "/tmp"))
socket_name = self.socket_name or "default"
if (
tmux_tmpdir is not None
and self.socket_path is None
and self.socket_name is None
and socket_name != "default"
):
self.socket_path = str(tmux_tmpdir / f"tmux-{os.geteuid()}" / socket_name)
if config_file:
self.config_file = config_file
if colors:
self.colors = colors
String representation of Server object
def __repr__(self) -> str:
"""Representation of :class:`Server` object."""
if self.socket_name is not None:
return (
f"{self.__class__.__name__}"
f"(socket_name={getattr(self, 'socket_name', 'default')})"
)
if self.socket_path is not None:
return f"{self.__class__.__name__}(socket_path={self.socket_path})"
return f"{self.__class__.__name__}(socket_path=/tmp/tmux-1000/default)"
Metadata
Metadata
Assignees
Labels
No labels