From 65079c74b08d4a0dc64bee6b23e4c3f3d583480f Mon Sep 17 00:00:00 2001 From: "Peter A. Jonsson" Date: Fri, 18 Jul 2025 20:35:49 +0200 Subject: [PATCH 1/2] tests: fix type error Only get the first 2 components of the server address. --- tests/conftest.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 0ef4db59..97047b15 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -29,7 +29,8 @@ def moto_server_uri(): else: s = server._server assert s is not None - host, port = s.server_address + # An AF_INET6 socket address has 4 components. + host, port = s.server_address[:2] uri = f"http://{host}:{port}" yield uri server.stop() From 16887cbe3a558c42fc38af110585ffde98d47c32 Mon Sep 17 00:00:00 2001 From: "Peter A. Jonsson" Date: Fri, 18 Jul 2025 20:28:16 +0200 Subject: [PATCH 2/2] Fix pyright config Use correct syntax for ignoring directories, add some ignores for missing module sources, and configure the environment so pyright can find the modules. --- obstore/python/obstore/__init__.py | 4 ++-- obstore/python/obstore/store.py | 11 ++++++++--- pyproject.toml | 10 +++++++++- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/obstore/python/obstore/__init__.py b/obstore/python/obstore/__init__.py index 7e4ff5c0..6a28793c 100644 --- a/obstore/python/obstore/__init__.py +++ b/obstore/python/obstore/__init__.py @@ -1,7 +1,7 @@ from typing import TYPE_CHECKING -from . import _obstore, store -from ._obstore import * # noqa: F403 +from . import _obstore, store # pyright:ignore[reportMissingModuleSource] +from ._obstore import * # noqa: F403 # pyright:ignore[reportMissingModuleSource] if TYPE_CHECKING: from . import exceptions # noqa: TC004 diff --git a/obstore/python/obstore/store.py b/obstore/python/obstore/store.py index 13b836cf..6c76f92e 100644 --- a/obstore/python/obstore/store.py +++ b/obstore/python/obstore/store.py @@ -5,8 +5,10 @@ from typing import TYPE_CHECKING, Union, overload import obstore as obs -from obstore._obstore import _store -from obstore._obstore import parse_scheme as _parse_scheme +from obstore._obstore import _store # pyright:ignore[reportMissingModuleSource] +from obstore._obstore import ( # pyright:ignore[reportMissingModuleSource] + parse_scheme as _parse_scheme, +) from obstore.exceptions import BaseError if TYPE_CHECKING: @@ -32,7 +34,10 @@ PutMode, PutResult, ) - from obstore._obstore import Bytes, GetResult + from obstore._obstore import ( # pyright:ignore[reportMissingModuleSource] + Bytes, + GetResult, + ) from obstore._store import ( AzureAccessKey, # noqa: TC004 AzureBearerToken, # noqa: TC004 diff --git a/pyproject.toml b/pyproject.toml index 4a7f653b..b015885e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -93,7 +93,15 @@ ignore = [ ] [tool.pyright] -exclude = ["examples/**"] +exclude = [ + "**/__pycache__", + "examples", + ".venv", +] +executionEnvironments = [ + { root = "./", extraPaths = ["./obstore/python"] }, # Tests. + { root = "./obstore/python" } +] [tool.pytest.ini_options] addopts = "-v --mypy-only-local-stub"