From 7a9dbe35ebe354115eaee7d0b21bcefd7a0d8bcd Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 26 Aug 2024 00:41:14 -0400 Subject: [PATCH] Pass mypy and link issues --- jaraco/postgres/__init__.py | 9 ++++++++- mypy.ini | 8 ++++++++ pyproject.toml | 5 +---- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/jaraco/postgres/__init__.py b/jaraco/postgres/__init__.py index 6f1dd9e..8fa90ad 100644 --- a/jaraco/postgres/__init__.py +++ b/jaraco/postgres/__init__.py @@ -48,6 +48,8 @@ log = logging.getLogger('jaraco.postgres') +_VERSION_PATTERN = re.compile(r'\d+(\.\d+)?') + class NotInitializedError(Exception): "An exception raised when an uninitialized DBMS is asked to do something" @@ -651,7 +653,12 @@ class PostgresFinder(paths.PathFinder): ] def _get_version_from_path(path: str): - version_str = re.search(r'\d+(\.\d+)?', path).group(0) # type: ignore + match = re.search(_VERSION_PATTERN, path) + if not match: + raise ValueError( + f"No version matching /{_VERSION_PATTERN.pattern}/ in '{path}'" + ) + version_str = match.group(0) return packaging.version.Version(version_str) # Prefer the highest-numbered version available. diff --git a/mypy.ini b/mypy.ini index efcb8cb..955ccfb 100644 --- a/mypy.ini +++ b/mypy.ini @@ -13,3 +13,11 @@ explicit_package_bases = True disable_error_code = # Disable due to many false positives overload-overlap, + +# jaraco/jaraco.services#5 +[mypy-jaraco.services.*] +ignore_missing_imports = True + +# jaraco/portend#17 +[mypy-portend.*] +ignore_missing_imports = True diff --git a/pyproject.toml b/pyproject.toml index 326fc0b..a8aa18c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,6 +68,7 @@ type = [ "pytest-mypy", # local + "types-psycopg2", ] @@ -76,7 +77,3 @@ pytest11 = {PostgreSQL = "jaraco.postgres.fixtures"} [tool.setuptools_scm] - - -[tool.pytest-enabler.mypy] -# Disabled due to jaraco/skeleton#143