Skip to content

Drop Python 3.7 #497

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 8 commits into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:

- name: Install poetry
if: env.PUBLISH == 'true'
run: pipx install "poetry==1.5.1"
run: pipx install "poetry==1.6.1"

- name: Set up Python ${{ matrix.python-version }}
if: env.PUBLISH == 'true'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.11"]
python-version: ["3.8", "3.11"]
tmux-version: ["2.6", "2.7", "2.8", "3.0a", "3.1b", "3.2a", "3.3a", "master"]
steps:
- uses: actions/checkout@v3

- name: Install poetry
run: pipx install "poetry==1.5.1"
run: pipx install "poetry==1.6.1"

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
- uses: actions/checkout@v3

- name: Install poetry
run: pipx install "poetry==1.5.1"
run: pipx install "poetry==1.6.1"

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
poetry 1.5.1
poetry 1.6.1
python 3.11.5 3.10.13 3.9.18 3.8.18 3.7.17
8 changes: 8 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ $ pip install --user --upgrade --pre libtmux

<!-- Maintainers and contributors: Insert change notes for the next release above -->

### Breaking changes

- Python 3.7 Dropped (#497)

### Development

- Poetry 1.5.1 -> 1.6.1 (#497)

## libtmux 0.23.2 (2023-09-09)

_Maintenance only, no bug fixes or new features_
Expand Down
491 changes: 208 additions & 283 deletions poetry.lock

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ classifiers = [
"Framework :: Pytest",
"Intended Audience :: Developers",
"Programming Language :: Python",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand Down Expand Up @@ -46,16 +45,16 @@ Repository = "https://github.com/tmux-python/libtmux"
Changes = "https://github.com/tmux-python/libtmux/blob/master/CHANGES"

[tool.poetry.dependencies]
python = "^3.7"
python = "^3.8"

[tool.poetry.group.dev.dependencies]
### Docs ###
sphinx = "*"
furo = "*"
gp-libs = "~0.0.1"
gp-libs = "~0.0.2"
sphinx-autobuild = "*"
sphinx-autodoc-typehints = "*"
sphinx-inline-tabs = "<2023.4.21" # For Python 3.7 support
sphinx-inline-tabs = "*"
sphinxext-opengraph = "<0.8" # https://github.com/wpilibsuite/sphinxext-opengraph/issues/100
sphinx-copybutton = "*"
sphinxext-rediraffe = "*"
Expand Down Expand Up @@ -129,7 +128,7 @@ exclude_lines = [
]

[tool.ruff]
target-version = "py37"
target-version = "py38"
select = [
"E", # pycodestyle
"F", # pyflakes
Expand Down
100 changes: 51 additions & 49 deletions src/libtmux/_internal/query_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,24 @@
"""
import re
import traceback
import typing as t
from collections.abc import Mapping, Sequence
from re import Pattern
from typing import TYPE_CHECKING, Any, Callable, List, Optional, TypeVar, Union

if TYPE_CHECKING:
from typing_extensions import Protocol
if t.TYPE_CHECKING:

class LookupProtocol(Protocol):
class LookupProtocol(t.Protocol):
"""Protocol for :class:`QueryList` filtering operators."""

def __call__(
self,
data: Union[str, List[str], "Mapping[str, str]"],
rhs: Union[str, List[str], "Mapping[str, str]", "Pattern[str]"],
data: t.Union[str, t.List[str], "Mapping[str, str]"],
rhs: t.Union[str, t.List[str], "Mapping[str, str]", "re.Pattern[str]"],
) -> bool:
"""Callback for :class:`QueryList` filtering operators."""
...


T = TypeVar("T", Any, Any)
T = t.TypeVar("T", t.Any, t.Any)

no_arg = object()

Expand All @@ -39,9 +37,9 @@ class ObjectDoesNotExist(Exception):


def keygetter(
obj: "Mapping[str, Any]",
obj: "Mapping[str, t.Any]",
path: str,
) -> Union[None, Any, str, List[str], "Mapping[str, str]"]:
) -> t.Union[None, t.Any, str, t.List[str], "Mapping[str, str]"]:
"""obj, "foods__breakfast", obj['foods']['breakfast']

>>> keygetter({ "foods": { "breakfast": "cereal" } }, "foods__breakfast")
Expand All @@ -67,7 +65,9 @@ def keygetter(
return dct


def parse_lookup(obj: "Mapping[str, Any]", path: str, lookup: str) -> Optional[Any]:
def parse_lookup(
obj: "Mapping[str, t.Any]", path: str, lookup: str
) -> t.Optional[t.Any]:
"""Check if field lookup key, e.g. "my__path__contains" has comparator, return val.

If comparator not used or value not found, return None.
Expand All @@ -88,15 +88,15 @@ def parse_lookup(obj: "Mapping[str, Any]", path: str, lookup: str) -> Optional[A


def lookup_exact(
data: Union[str, List[str], "Mapping[str, str]"],
rhs: Union[str, List[str], "Mapping[str, str]", "Pattern[str]"],
data: t.Union[str, t.List[str], "Mapping[str, str]"],
rhs: t.Union[str, t.List[str], "Mapping[str, str]", "re.Pattern[str]"],
) -> bool:
return rhs == data


def lookup_iexact(
data: Union[str, List[str], "Mapping[str, str]"],
rhs: Union[str, List[str], "Mapping[str, str]", "Pattern[str]"],
data: t.Union[str, t.List[str], "Mapping[str, str]"],
rhs: t.Union[str, t.List[str], "Mapping[str, str]", "re.Pattern[str]"],
) -> bool:
if not isinstance(rhs, str) or not isinstance(data, str):
return False
Expand All @@ -105,8 +105,8 @@ def lookup_iexact(


def lookup_contains(
data: Union[str, List[str], "Mapping[str, str]"],
rhs: Union[str, List[str], "Mapping[str, str]", "Pattern[str]"],
data: t.Union[str, t.List[str], "Mapping[str, str]"],
rhs: t.Union[str, t.List[str], "Mapping[str, str]", "re.Pattern[str]"],
) -> bool:
if not isinstance(rhs, str) or not isinstance(data, (str, Mapping, list)):
return False
Expand All @@ -115,8 +115,8 @@ def lookup_contains(


def lookup_icontains(
data: Union[str, List[str], "Mapping[str, str]"],
rhs: Union[str, List[str], "Mapping[str, str]", "Pattern[str]"],
data: t.Union[str, t.List[str], "Mapping[str, str]"],
rhs: t.Union[str, t.List[str], "Mapping[str, str]", "re.Pattern[str]"],
) -> bool:
if not isinstance(rhs, str) or not isinstance(data, (str, Mapping, list)):
return False
Expand All @@ -130,8 +130,8 @@ def lookup_icontains(


def lookup_startswith(
data: Union[str, List[str], "Mapping[str, str]"],
rhs: Union[str, List[str], "Mapping[str, str]", "Pattern[str]"],
data: t.Union[str, t.List[str], "Mapping[str, str]"],
rhs: t.Union[str, t.List[str], "Mapping[str, str]", "re.Pattern[str]"],
) -> bool:
if not isinstance(rhs, str) or not isinstance(data, str):
return False
Expand All @@ -140,8 +140,8 @@ def lookup_startswith(


def lookup_istartswith(
data: Union[str, List[str], "Mapping[str, str]"],
rhs: Union[str, List[str], "Mapping[str, str]", "Pattern[str]"],
data: t.Union[str, t.List[str], "Mapping[str, str]"],
rhs: t.Union[str, t.List[str], "Mapping[str, str]", "re.Pattern[str]"],
) -> bool:
if not isinstance(rhs, str) or not isinstance(data, str):
return False
Expand All @@ -150,8 +150,8 @@ def lookup_istartswith(


def lookup_endswith(
data: Union[str, List[str], "Mapping[str, str]"],
rhs: Union[str, List[str], "Mapping[str, str]", "Pattern[str]"],
data: t.Union[str, t.List[str], "Mapping[str, str]"],
rhs: t.Union[str, t.List[str], "Mapping[str, str]", "re.Pattern[str]"],
) -> bool:
if not isinstance(rhs, str) or not isinstance(data, str):
return False
Expand All @@ -160,17 +160,17 @@ def lookup_endswith(


def lookup_iendswith(
data: Union[str, List[str], "Mapping[str, str]"],
rhs: Union[str, List[str], "Mapping[str, str]", "Pattern[str]"],
data: t.Union[str, t.List[str], "Mapping[str, str]"],
rhs: t.Union[str, t.List[str], "Mapping[str, str]", "re.Pattern[str]"],
) -> bool:
if not isinstance(rhs, str) or not isinstance(data, str):
return False
return data.lower().endswith(rhs.lower())


def lookup_in(
data: Union[str, List[str], "Mapping[str, str]"],
rhs: Union[str, List[str], "Mapping[str, str]", "Pattern[str]"],
data: t.Union[str, t.List[str], "Mapping[str, str]"],
rhs: t.Union[str, t.List[str], "Mapping[str, str]", "re.Pattern[str]"],
) -> bool:
if isinstance(rhs, list):
return data in rhs
Expand All @@ -191,8 +191,8 @@ def lookup_in(


def lookup_nin(
data: Union[str, List[str], "Mapping[str, str]"],
rhs: Union[str, List[str], "Mapping[str, str]", "Pattern[str]"],
data: t.Union[str, t.List[str], "Mapping[str, str]"],
rhs: t.Union[str, t.List[str], "Mapping[str, str]", "re.Pattern[str]"],
) -> bool:
if isinstance(rhs, list):
return data not in rhs
Expand All @@ -213,17 +213,17 @@ def lookup_nin(


def lookup_regex(
data: Union[str, List[str], "Mapping[str, str]"],
rhs: Union[str, List[str], "Mapping[str, str]", "Pattern[str]"],
data: t.Union[str, t.List[str], "Mapping[str, str]"],
rhs: t.Union[str, t.List[str], "Mapping[str, str]", "re.Pattern[str]"],
) -> bool:
if isinstance(data, (str, bytes, re.Pattern)) and isinstance(rhs, (str, bytes)):
return bool(re.search(rhs, data))
return False


def lookup_iregex(
data: Union[str, List[str], "Mapping[str, str]"],
rhs: Union[str, List[str], "Mapping[str, str]", "Pattern[str]"],
data: t.Union[str, t.List[str], "Mapping[str, str]"],
rhs: t.Union[str, t.List[str], "Mapping[str, str]", "re.Pattern[str]"],
) -> bool:
if isinstance(data, (str, bytes, re.Pattern)) and isinstance(rhs, (str, bytes)):
return bool(re.search(rhs, data, re.IGNORECASE))
Expand Down Expand Up @@ -257,7 +257,7 @@ def __init__(self, op: str, *args: object):
return super().__init__(f"{op} not in LOOKUP_NAME_MAP")


class QueryList(List[T]):
class QueryList(t.List[T]):
"""Filter list of object/dictionaries. For small, local datasets.

*Experimental, unstable*.
Expand Down Expand Up @@ -293,21 +293,21 @@ class QueryList(List[T]):
"""

data: "Sequence[T]"
pk_key: Optional[str]
pk_key: t.Optional[str]

def items(self) -> List[T]:
def items(self) -> t.List[T]:
if self.pk_key is None:
raise PKRequiredException()
return [(getattr(item, self.pk_key), item) for item in self]

def __eq__(
self,
other: object,
# other: Union[
# other: t.Union[
# "QueryList[T]",
# List[Mapping[str, str]],
# List[Mapping[str, int]],
# List[Mapping[str, Union[str, Mapping[str, Union[List[str], str]]]]],
# t.List[Mapping[str, str]],
# t.List[Mapping[str, int]],
# t.List[Mapping[str, t.Union[str, Mapping[str, t.Union[List[str], str]]]]],
# ],
) -> bool:
data = other
Expand All @@ -331,11 +331,13 @@ def __eq__(
return False

def filter(
self, matcher: Optional[Union[Callable[[T], bool], T]] = None, **kwargs: Any
self,
matcher: t.Optional[t.Union[t.Callable[[T], bool], T]] = None,
**kwargs: t.Any,
) -> "QueryList[T]":
"""Filter list of objects."""

def filter_lookup(obj: Any) -> bool:
def filter_lookup(obj: t.Any) -> bool:
for path, v in kwargs.items():
try:
lhs, op = path.rsplit("__", 1)
Expand All @@ -359,7 +361,7 @@ def filter_lookup(obj: Any) -> bool:
_filter = matcher
elif matcher is not None:

def val_match(obj: Union[str, List[Any]]) -> bool:
def val_match(obj: t.Union[str, t.List[t.Any]]) -> bool:
if isinstance(matcher, list):
return obj in matcher
else:
Expand All @@ -373,10 +375,10 @@ def val_match(obj: Union[str, List[Any]]) -> bool:

def get(
self,
matcher: Optional[Union[Callable[[T], bool], T]] = None,
default: Optional[Any] = no_arg,
**kwargs: Any,
) -> Optional[T]:
matcher: t.Optional[t.Union[t.Callable[[T], bool], T]] = None,
default: t.Optional[t.Any] = no_arg,
**kwargs: t.Any,
) -> t.Optional[T]:
"""Retrieve one object.

Raises :exc:`MultipleObjectsReturned` if multiple objects found.
Expand Down
4 changes: 1 addition & 3 deletions src/libtmux/neo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
from libtmux.formats import FORMAT_SEPARATOR

if t.TYPE_CHECKING:
from typing_extensions import Literal

ListCmd = Literal["list-sessions", "list-windows", "list-panes"]
ListCmd = t.Literal["list-sessions", "list-windows", "list-panes"]
ListExtraArgs = t.Optional[t.Iterable[str]]

from libtmux.server import Server
Expand Down
10 changes: 4 additions & 6 deletions src/libtmux/pane.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
from . import exc

if t.TYPE_CHECKING:
from typing_extensions import Literal

from .server import Server
from .session import Session
from .window import Window
Expand Down Expand Up @@ -158,8 +156,8 @@ def resize_pane(self, *args: t.Any, **kwargs: t.Any) -> "Pane":

def capture_pane(
self,
start: t.Union["Literal['-']", t.Optional[int]] = None,
end: t.Union["Literal['-']", t.Optional[int]] = None,
start: t.Union["t.Literal['-']", t.Optional[int]] = None,
end: t.Union["t.Literal['-']", t.Optional[int]] = None,
) -> t.Union[str, t.List[str]]:
"""
Capture text from pane.
Expand Down Expand Up @@ -248,12 +246,12 @@ def send_keys(

@overload
def display_message(
self, cmd: str, get_text: "Literal[True]"
self, cmd: str, get_text: "t.Literal[True]"
) -> t.Union[str, t.List[str]]:
...

@overload
def display_message(self, cmd: str, get_text: "Literal[False]") -> None:
def display_message(self, cmd: str, get_text: "t.Literal[False]") -> None:
...

def display_message(
Expand Down
Loading