Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def mypy(session):
"--no-default-groups",
"--group",
"mypy",
"--group",
"dev",
"--extra",
"webdriver",
"--group",
Expand All @@ -49,6 +51,26 @@ def mypy(session):
session.run("mypy", ".", *session.posargs)


@nox.session
def ty(session):
session.run_install(
"uv",
"sync",
"--no-install-workspace",
"--no-default-groups",
"--group",
"ty",
"--group",
"dev",
"--extra",
"webdriver",
"--group",
"test",
env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location},
)
session.run("ty", "check", *session.posargs)


@nox.session
def docs(session: nox.Session):
session.run_install(
Expand Down
17 changes: 11 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ module = [
"google.*",
"zarr",
"zarrita",
"tensorstore",
"dask",
"dask.*",
"scipy",
Expand All @@ -100,17 +99,20 @@ dev = [
"requests>=2.32.3",
"selenium>=4",
"tensorstore>=0.1.71",
"pandas-stubs>=2.2.3.241126",
"types-atomicwrites>=1.4.5.1",
"types-pillow>=10.2.0.20240822",
"types-requests>=2.32.0.20241016",
"types-setuptools>=75.8.0.20250110",
]
ruff = [
"ruff==0.3.2",
]
mypy = [
"mypy>=1.14.1",
"pandas-stubs>=2.2.3.241126",
"types-atomicwrites>=1.4.5.1",
"types-pillow>=10.2.0.20240822",
"types-requests>=2.32.0.20241016",
"types-setuptools>=75.8.0.20250110",
]
ty = [
"ty",
]
test = [
"pytest>=6.1.2",
Expand Down Expand Up @@ -141,3 +143,6 @@ default-groups = ["dev", "ruff", "mypy", "test", "docs"]
testpaths = [
"python/tests",
]

[tool.ty.src]
include = ["python"]
1 change: 1 addition & 0 deletions python/neuroglancer/json_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"""Facilities for converting JSON <-> Python objects"""

import collections
import collections.abc
import copy
import inspect
import numbers
Expand Down
2 changes: 1 addition & 1 deletion python/neuroglancer/local_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
try:
import tensorstore as ts
except ImportError:
ts = None
ts = None # type: ignore[assignment]

from . import downsample, downsample_scales, trackable_state
from .chunks import encode_jpeg, encode_npz, encode_raw
Expand Down
Empty file added python/neuroglancer/py.typed
Empty file.
6 changes: 3 additions & 3 deletions python/neuroglancer/read_precomputed_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ def __contains__(self, key: K) -> bool:
"""Checks if a given key is present."""
if self._kvstore is None:
raise KeyError("required index kind not available")
return self._key_encoder(key) in self._kvstore
return self._key_encoder(key) in self._kvstore # type: ignore[operator]

def get(self, key: K, batch: ts.Batch | None = None) -> ts.Future:
def get(self, key: K, batch: ts.Batch | None = None) -> ts.Future[V | None]:
"""Reads a given key, returning a Future."""
if self._kvstore is None:
raise KeyError("required index kind not available")
promise, future = ts.Promise.new()
promise, future = ts.Promise[V | None].new()

def done_callback(future):
try:
Expand Down
2 changes: 1 addition & 1 deletion python/neuroglancer/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@

global_server_args = dict(bind_address="127.0.0.1", bind_port=0)

debug = False
debug: bool = False

_IS_GOOGLE_COLAB = "google.colab" in sys.modules

Expand Down
13 changes: 9 additions & 4 deletions python/neuroglancer/viewer_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@


import collections
import collections.abc
import contextlib
import json
import re
Expand Down Expand Up @@ -190,9 +191,9 @@ def volume_info(
layer: str,
*,
dimensions: coordinate_space.CoordinateSpace | None = None,
) -> "Future[ts.TensorStore]":
) -> "Future[viewer_config_state.VolumeInfo]":
request_id = make_random_token()
future: Future[ts.TensorStore] = Future()
future: Future[viewer_config_state.VolumeInfo] = Future()
self._volume_info_promises[request_id] = future

def add_request(s):
Expand Down Expand Up @@ -230,8 +231,12 @@ def info_done(info_future):
)
]

def read_function(domain: ts.IndexDomain, array, params):
read_promise, read_future = ts.Promise.new()
def read_function(
domain: ts.IndexDomain,
array: np.ndarray,
params: ts.VirtualChunkedReadParameters,
) -> ts.Future[None]:
read_promise, read_future = ts.Promise[None].new()
origin = domain.origin
grid_origin = info.grid_origin
chunk_shape = info.chunk_shape
Expand Down
642 changes: 341 additions & 301 deletions uv.lock

Large diffs are not rendered by default.

Loading