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 83b0d15..a4a7a45 100644 --- a/mypy.ini +++ b/mypy.ini @@ -12,3 +12,11 @@ explicit_package_bases = True # Disable overload-overlap due to many false-positives disable_error_code = 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