From 59b93ed112853205d10448255582796d6fda0883 Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Wed, 21 Feb 2024 08:43:05 +0100 Subject: [PATCH 1/2] Drop support for Python 3.7 This version has reached its end-of-life last year, https://peps.python.org/pep-0537/#lifespan. --- .github/workflows/tests.yml | 2 +- CHANGELOG.md | 4 ++++ README.md | 2 +- pgactivity/compat.py | 7 +------ pyproject.toml | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 83563394..4d1777ba 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: include: - - python: "3.7" + - python: "3.8" psycopg: "psycopg2" - python: "3.12" psycopg: "psycopg3" diff --git a/CHANGELOG.md b/CHANGELOG.md index cb1b000f..9d1e3a3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ * Fix retrieval of I/O statistics on BSD systems (#393). * Fix spelling mistakes in the man page. +### Removed + +* Python 3.7 is no longer supported. + ### Misc * Document how to *hack* on pg\_activity in the `README`. diff --git a/README.md b/README.md index 4f7d8fcd..532c076b 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ pg\_activity releases. Before submitting a bug report here: ## From PyPI -pg\_activity can be installed using pip on Python 3.7 or later along with +pg\_activity can be installed using pip on Python 3.8 or later along with psycopg: $ python3 -m pip install "pg_activity[psycopg]" diff --git a/pgactivity/compat.py b/pgactivity/compat.py index a15048a4..4be71a25 100644 --- a/pgactivity/compat.py +++ b/pgactivity/compat.py @@ -1,16 +1,11 @@ import operator -import sys +from importlib.metadata import version from typing import Any, Dict import attr import attr.validators import blessed -if sys.version_info < (3, 8): - from importlib_metadata import version -else: - from importlib.metadata import version - ATTR_VERSION = tuple(int(x) for x in version("attrs").split(".", 2)[:2]) BLESSED_VERSION = tuple(int(x) for x in version("blessed").split(".", 2)[:2]) diff --git a/pyproject.toml b/pyproject.toml index bc71136d..ff3c1c2e 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.7" +requires-python = ">=3.8" authors = [ { name = "Julien Tachoires", email = "julmon@gmail.com" }, { name = "Benoit Lobréau", email = "benoit.lobreau@dalibo.com" }, From 6b0edb86c014cf1a32e2138be09ee472960b03e6 Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Wed, 21 Feb 2024 08:50:40 +0100 Subject: [PATCH 2/2] Configure usage of pyupgrade and upgrade our code base --- .pre-commit-config.yaml | 5 +++++ pgactivity/types.py | 2 +- pyproject.toml | 1 + tox.ini | 3 +++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fc2a8bf2..8705a7c1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,6 +12,11 @@ repos: exclude: tests/test_*.txt - repo: local hooks: + - id: pyupgrade + name: pyupgrade + entry: pyupgrade --py38-plus --exit-zero-even-if-changed + language: system + types: [python] - id: black name: black entry: black --check . diff --git a/pgactivity/types.py b/pgactivity/types.py index beb3def9..4a442c1a 100644 --- a/pgactivity/types.py +++ b/pgactivity/types.py @@ -278,7 +278,7 @@ def add_column(key: str, name: str, **kwargs: Any) -> None: key="database", name="DATABASE(*)" if filters.dbname else "DATABASE", min_width=max_db_length, - transform=functools.lru_cache()( + transform=functools.lru_cache( lambda v: utils.ellipsis(v, width=16) if v else "", ), sort_key=None, diff --git a/pyproject.toml b/pyproject.toml index ff3c1c2e..c3e525bb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,6 +52,7 @@ dev = [ "flake8", "isort", "pre-commit", + "pyupgrade", ] typing = [ "mypy", diff --git a/tox.ini b/tox.ini index 37031df9..79820d39 100644 --- a/tox.ini +++ b/tox.ini @@ -27,11 +27,14 @@ deps = black >= 24.2.0 flake8 isort + pre-commit + pyupgrade commands = codespell {toxinidir} black --check --diff {toxinidir} flake8 {toxinidir} isort --check --diff {toxinidir} + pre-commit run --all-files --show-diff-on-failure pyupgrade [testenv:mypy] extras =