Skip to content

Commit 650613c

Browse files
pjonssonkylebarron
andauthored
fix: fix pyright config (#505)
* tests: fix type error Only get the first 2 components of the server address. * 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. --------- Co-authored-by: Kyle Barron <kyle@developmentseed.org>
1 parent 0237991 commit 650613c

4 files changed

Lines changed: 21 additions & 7 deletions

File tree

obstore/python/obstore/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import TYPE_CHECKING
22

3-
from . import _obstore, store
4-
from ._obstore import * # noqa: F403
3+
from . import _obstore, store # pyright:ignore[reportMissingModuleSource]
4+
from ._obstore import * # noqa: F403 # pyright:ignore[reportMissingModuleSource]
55

66
if TYPE_CHECKING:
77
from . import exceptions # noqa: TC004

obstore/python/obstore/store.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
from typing import TYPE_CHECKING, Union, overload
66

77
import obstore as obs
8-
from obstore._obstore import _store
9-
from obstore._obstore import parse_scheme as _parse_scheme
8+
from obstore._obstore import _store # pyright:ignore[reportMissingModuleSource]
9+
from obstore._obstore import ( # pyright:ignore[reportMissingModuleSource]
10+
parse_scheme as _parse_scheme,
11+
)
1012
from obstore.exceptions import BaseError
1113

1214
if TYPE_CHECKING:
@@ -32,7 +34,10 @@
3234
PutMode,
3335
PutResult,
3436
)
35-
from obstore._obstore import Bytes, GetResult
37+
from obstore._obstore import ( # pyright:ignore[reportMissingModuleSource]
38+
Bytes,
39+
GetResult,
40+
)
3641
from obstore._store import (
3742
AzureAccessKey, # noqa: TC004
3843
AzureBearerToken, # noqa: TC004

pyproject.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,15 @@ ignore = [
9393
]
9494

9595
[tool.pyright]
96-
exclude = ["examples/**"]
96+
exclude = [
97+
"**/__pycache__",
98+
"examples",
99+
".venv",
100+
]
101+
executionEnvironments = [
102+
{ root = "./", extraPaths = ["./obstore/python"] }, # Tests.
103+
{ root = "./obstore/python" }
104+
]
97105

98106
[tool.pytest.ini_options]
99107
addopts = "-v --mypy-only-local-stub"

tests/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ def moto_server_uri():
2929
else:
3030
s = server._server
3131
assert s is not None
32-
host, port = s.server_address
32+
# An AF_INET6 socket address has 4 components.
33+
host, port = s.server_address[:2]
3334
uri = f"http://{host}:{port}"
3435
yield uri
3536
server.stop()

0 commit comments

Comments
 (0)