From c93519020a97a7db3f711ae9901804974fea68ec Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Tue, 8 Oct 2024 11:47:31 +0200 Subject: [PATCH] Drop support for Python 3.8 Python 3.8 has reached its end-of-life: https://peps.python.org/pep-0569/ --- .github/workflows/tests.yml | 2 +- CHANGELOG.md | 4 ++++ pgactivity/activities.py | 2 +- pgactivity/cli.py | 15 +++++++-------- pgactivity/compat.py | 24 ------------------------ pgactivity/pg.py | 5 ++--- pgactivity/queries/__init__.py | 2 +- pgactivity/types.py | 10 +++++----- pgactivity/ui.py | 4 ++-- pgactivity/utils.py | 3 ++- pgactivity/views.py | 3 ++- pyproject.toml | 2 +- 12 files changed, 28 insertions(+), 48 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fd639eab..32c1aa06 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: include: - - python: "3.8" + - python: "3.9" psycopg: "psycopg2" - python: "3.12" psycopg: "psycopg3" diff --git a/CHANGELOG.md b/CHANGELOG.md index 4060f54b..1f75c850 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,10 @@ * Exit with status 0 upon keyboard interrupt. +### Removed + +* Python 3.8 is no longer supported. + ## pg\_activity 3.5.1 - 2024-04-03 ### Fixed diff --git a/pgactivity/activities.py b/pgactivity/activities.py index 6cc596f0..e7127e10 100644 --- a/pgactivity/activities.py +++ b/pgactivity/activities.py @@ -3,13 +3,13 @@ import builtins import os import time +from collections.abc import Sequence from typing import TypeVar from warnings import catch_warnings, simplefilter import attr import psutil -from .compat import Sequence from .types import ( BlockingProcess, IOCounter, diff --git a/pgactivity/cli.py b/pgactivity/cli.py index 2a97e6b3..d3642982 100755 --- a/pgactivity/cli.py +++ b/pgactivity/cli.py @@ -47,14 +47,13 @@ def configure_logger(debug_file: str | None = None) -> StringIO: def flag(p: Any, spec: str, *, dest: str, feature: str) -> None: assert not spec.startswith("--no-") and spec.startswith("--"), spec - if sys.version_info < (3, 9): - spec = f"--no-{spec[2:]}" - action = "store_false" - help = f"Disable {feature}." - else: - action = argparse.BooleanOptionalAction - help = f"Enable/disable {feature}." - p.add_argument(spec, dest=dest, help=help, action=action, default=None) + p.add_argument( + spec, + dest=dest, + help=f"Enable/disable {feature}.", + action=argparse.BooleanOptionalAction, + default=None, + ) def get_parser() -> argparse.ArgumentParser: diff --git a/pgactivity/compat.py b/pgactivity/compat.py index 6b872ac0..16c341c5 100644 --- a/pgactivity/compat.py +++ b/pgactivity/compat.py @@ -10,30 +10,6 @@ import attr.validators import blessed -__all__ = [ - "Callable", - "Dict", - "Iterable", - "Iterator", - "Mapping", - "MutableSet", - "Sequence", -] - -if sys.version_info >= (3, 9): - from collections.abc import ( - Callable, - Iterable, - Iterator, - Mapping, - MutableSet, - Sequence, - ) - - Dict = dict -else: - from typing import Callable, Dict, Iterable, Iterator, Mapping, MutableSet, Sequence - if sys.version_info >= (3, 11): def read_resource(pkgname: str, dirname: str, *args: str) -> str | None: diff --git a/pgactivity/pg.py b/pgactivity/pg.py index 5b1a0c92..3c82a82d 100644 --- a/pgactivity/pg.py +++ b/pgactivity/pg.py @@ -2,10 +2,9 @@ import logging import os +from collections.abc import Callable, Sequence from typing import Any, TypeVar, overload -from .compat import Callable, Dict, Sequence - Row = TypeVar("Row") try: @@ -29,7 +28,7 @@ __version__ = psycopg.__version__ - Connection = psycopg.Connection[Dict[str, Any]] + Connection = psycopg.Connection[dict[str, Any]] class BytesLoader(Loader): def load(self, data: Buffer) -> bytes: diff --git a/pgactivity/queries/__init__.py b/pgactivity/queries/__init__.py index 63be06a0..bb629db7 100644 --- a/pgactivity/queries/__init__.py +++ b/pgactivity/queries/__init__.py @@ -4,7 +4,7 @@ here = pathlib.Path(__file__).parent -@functools.lru_cache(maxsize=None) +@functools.cache def get(name: str) -> str: path = here / f"{name}.sql" with path.open() as f: diff --git a/pgactivity/types.py b/pgactivity/types.py index 28119057..8f6bd2ff 100644 --- a/pgactivity/types.py +++ b/pgactivity/types.py @@ -2,16 +2,16 @@ import enum import functools +from collections.abc import Callable, Iterable, Iterator, Mapping, MutableSet, Sequence from datetime import timedelta from ipaddress import IPv4Address, IPv6Address -from typing import Any, Tuple, TypeVar, Union, overload +from typing import Any, TypeVar, Union, overload import attr import psutil from attr import validators from . import colors, compat, pg, utils -from .compat import Callable, Iterable, Iterator, Mapping, MutableSet, Sequence from .config import Configuration, Flag, HeaderSection, UISection @@ -1186,7 +1186,7 @@ def copy_focused_query_to_clipboard(self) -> str: ActivityStats = Union[ Iterable[WaitingProcess], Iterable[RunningProcess], - Tuple[Iterable[WaitingProcess], SystemInfo], - Tuple[Iterable[BlockingProcess], SystemInfo], - Tuple[Iterable[LocalRunningProcess], SystemInfo], + tuple[Iterable[WaitingProcess], SystemInfo], + tuple[Iterable[BlockingProcess], SystemInfo], + tuple[Iterable[LocalRunningProcess], SystemInfo], ] diff --git a/pgactivity/ui.py b/pgactivity/ui.py index 520926a0..0cd68d9f 100644 --- a/pgactivity/ui.py +++ b/pgactivity/ui.py @@ -3,7 +3,7 @@ import time from argparse import Namespace from functools import partial -from typing import List, cast +from typing import cast import attr from blessed import Terminal @@ -216,7 +216,7 @@ def main( if is_local: # TODO: Use this logic in waiting and blocking cases. local_pg_procs, io_read, io_write = activities.ps_complete( - cast(List[types.RunningProcess], pg_procs.items), + cast(list[types.RunningProcess], pg_procs.items), sys_procs, fs_blocksize, ) diff --git a/pgactivity/utils.py b/pgactivity/utils.py index 4127d242..1ebc2fe4 100644 --- a/pgactivity/utils.py +++ b/pgactivity/utils.py @@ -4,8 +4,9 @@ import functools import re import sys +from collections.abc import Iterable, Mapping from datetime import datetime, timedelta, timezone -from typing import IO, Any, Iterable, Mapping +from typing import IO, Any import attr import humanize diff --git a/pgactivity/views.py b/pgactivity/views.py index 454f477e..b8720afc 100644 --- a/pgactivity/views.py +++ b/pgactivity/views.py @@ -3,6 +3,7 @@ import functools import inspect import itertools +from collections.abc import Callable, Iterable, Iterator, Sequence from textwrap import TextWrapper, dedent from typing import Any, Literal @@ -10,7 +11,7 @@ from . import colors, utils from .activities import sorted as sorted_processes -from .compat import Callable, Iterable, Iterator, Sequence, link +from .compat import link from .keys import BINDINGS, EXIT_KEY from .keys import HELP as HELP_KEY from .keys import ( diff --git a/pyproject.toml b/pyproject.toml index 8f34b4c5..c20dec4e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ dynamic = ["version"] description = "Command line tool for PostgreSQL server activity monitoring." readme = "README.md" license = { text = "PostgreSQL" } -requires-python = ">=3.8" +requires-python = ">=3.9" authors = [ { name = "Julien Tachoires", email = "julmon@gmail.com" }, { name = "Benoit Lobréau", email = "benoit.lobreau@dalibo.com" },