From 4e39ca983f46c64e2e5d155691226086c6f66b07 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Dec 2023 02:41:06 +0000 Subject: [PATCH 1/2] Bump black from 23.11.0 to 23.12.0 Bumps [black](https://github.com/psf/black) from 23.11.0 to 23.12.0. - [Release notes](https://github.com/psf/black/releases) - [Changelog](https://github.com/psf/black/blob/main/CHANGES.md) - [Commits](https://github.com/psf/black/compare/23.11.0...23.12.0) --- updated-dependencies: - dependency-name: black dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Pipfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pipfile b/Pipfile index 1c45e30c..ea975c84 100644 --- a/Pipfile +++ b/Pipfile @@ -14,7 +14,7 @@ towncrier = "==23.11.0" pytest-cov = "==4.1.0" pytest-xdist = "==3.5.0" mock = "==5.1.0" -black = "==23.11.0" +black = "==23.12.0" mypy = "==1.7.1" types-setuptools = "==69.0.0.0" tbump = "==6.11.0" From fcb1c4989fee41ab8f5581c9adae68c1b913126e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Grzegorz=20=C5=9Aliwi=C5=84ski?= Date: Fri, 15 Dec 2023 13:19:24 +0100 Subject: [PATCH 2/2] Stop Relying in pkg_resources, and use packaging.version instead --- newsfragments/858.misc.rst | 1 + pytest_postgresql/executor.py | 6 +++--- pytest_postgresql/executor_noop.py | 4 ++-- pytest_postgresql/janitor.py | 6 +++--- tests/test_executor.py | 4 ++-- tests/test_janitor.py | 4 ++-- 6 files changed, 13 insertions(+), 12 deletions(-) create mode 100644 newsfragments/858.misc.rst diff --git a/newsfragments/858.misc.rst b/newsfragments/858.misc.rst new file mode 100644 index 00000000..3e42f0fe --- /dev/null +++ b/newsfragments/858.misc.rst @@ -0,0 +1 @@ +Replace usage of `pkg_resources.parse_version` with `packaging.version.parse` diff --git a/pytest_postgresql/executor.py b/pytest_postgresql/executor.py index 0fded30d..5c2800b9 100644 --- a/pytest_postgresql/executor.py +++ b/pytest_postgresql/executor.py @@ -28,7 +28,7 @@ from mirakuru import TCPExecutor from mirakuru.exceptions import ProcessFinishedWithError -from pkg_resources import parse_version +from packaging.version import parse from pytest_postgresql.exceptions import ExecutableMissingException, PostgreSQLUnsupported @@ -57,7 +57,7 @@ class PostgreSQLExecutor(TCPExecutor): ) VERSION_RE = re.compile(r".* (?P\d+(?:\.\d+)?)") - MIN_SUPPORTED_VERSION = parse_version("10") + MIN_SUPPORTED_VERSION = parse("10") def __init__( self, @@ -203,7 +203,7 @@ def version(self) -> Any: ) from ex matches = self.VERSION_RE.search(version_string) assert matches is not None - return parse_version(matches.groupdict()["version"]) + return parse(matches.groupdict()["version"]) def running(self) -> bool: """Check if server is running.""" diff --git a/pytest_postgresql/executor_noop.py b/pytest_postgresql/executor_noop.py index 65c59f2b..68d53fcf 100644 --- a/pytest_postgresql/executor_noop.py +++ b/pytest_postgresql/executor_noop.py @@ -19,7 +19,7 @@ from typing import Any, Optional, Union import psycopg -from pkg_resources import parse_version +from packaging.version import parse class NoopExecutor: @@ -84,5 +84,5 @@ def version(self) -> Any: if not int(part): continue version_parts.append(part) - self._version = parse_version(".".join(version_parts[:2])) + self._version = parse(".".join(version_parts[:2])) return self._version diff --git a/pytest_postgresql/janitor.py b/pytest_postgresql/janitor.py index 76d8308a..e75767d6 100644 --- a/pytest_postgresql/janitor.py +++ b/pytest_postgresql/janitor.py @@ -6,13 +6,13 @@ from typing import Callable, Iterator, Optional, Type, TypeVar, Union import psycopg -from pkg_resources import parse_version +from packaging.version import parse from psycopg import Connection, Cursor from pytest_postgresql.retry import retry from pytest_postgresql.sql import loader -Version = type(parse_version("1")) +Version = type(parse("1")) DatabaseJanitorType = TypeVar("DatabaseJanitorType", bound="DatabaseJanitor") @@ -53,7 +53,7 @@ def __init__( self._connection_timeout = connection_timeout self.isolation_level = isolation_level if not isinstance(version, Version): - self.version = parse_version(str(version)) + self.version = parse(str(version)) else: self.version = version diff --git a/tests/test_executor.py b/tests/test_executor.py index 05074dd4..51a7deb1 100644 --- a/tests/test_executor.py +++ b/tests/test_executor.py @@ -4,7 +4,7 @@ import psycopg import pytest -from pkg_resources import parse_version +from packaging.version import parse from port_for import get_port from psycopg import Connection from pytest import FixtureRequest @@ -22,7 +22,7 @@ class PatchedPostgreSQLExecutor(PostgreSQLExecutor): @property def version(self) -> Any: """Overwrite version, to always return highest unsupported version.""" - return parse_version("8.9") + return parse("8.9") def test_unsupported_version(request: FixtureRequest) -> None: diff --git a/tests/test_janitor.py b/tests/test_janitor.py index 694d3e20..d57ee2dd 100644 --- a/tests/test_janitor.py +++ b/tests/test_janitor.py @@ -4,11 +4,11 @@ from unittest.mock import MagicMock, patch import pytest -from pkg_resources import parse_version +from packaging.version import parse from pytest_postgresql.janitor import DatabaseJanitor -VERSION = parse_version("10") +VERSION = parse("10") @pytest.mark.parametrize("version", (VERSION, 10, "10"))