tmux-python / tmux-python/libtmux
QueryList exception do not inherit from libtmux.exc.LibTmuxException
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.2k
- Forks
- 127
- Avg merge
- 2h 13m
- Merged PRs (30d)
- 1
Description
I was porting today a legacy piece of software (written by another co-worker, I only maintain it) that was using libtmux-0.8.5 und made an upgrade to libtmux-0.24.0 and I was getting a lot of deprecation errors because of session.find_where usage.
The code looked mostly like this:
try:
session = libtmux.Server().find_where({"session_name":session_name})
except libtmux.exc.LibTmuxException:
session = libtmux.Server().new_session(session_name=session_name)
and I changed it to
tmux_server = libtmux.server.Server()
try:
session = tmux_server.sessions.get(session_name=session_name)
except libtmux.exc.LibTmuxException:
session = tmux_server.new_session(session_name=session_name)
I realized that when sessions.get does not found a session, it raises ObjectDoesNotExist. But ObjectDoesNotExist is declared like this:
class ObjectDoesNotExist(Exception):
"""The requested object does not exist."""
The problem is that ObjectDoesNotExist is actually defined in libtmux._internal.query_list.py while the the documentation says here https://libtmux.git-pull.com/reference/exceptions.html
exception libtmux.exc.LibTmuxException Base Exception for libtmux Errors.
I don't want to start importing stuff from submodules with a leading underscore as this is mostly used by "private" modules and cannot be considered part of the public API.
I think you should either expose those exception directly in the top __init__.py and at least make ObjectDoesNotExist and ObjectDoesNotExist both inherit from libtmux.exc.LibTmuxException to keep it consistent.
Is there a reason why the the query_list implementation is the ._internal private submodule and why those exceptions do not inherit from libtmux.exc.LibTmuxException?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with libtmux._internal.query_list.py and libtmux.exc to compare ObjectDoesNotExist with LibTmuxException, then inspect the top-level init.py and the documented exceptions reference. Done means the query exception hierarchy and public exposure match the supported API, with the intended behavior for sessions.get established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100