Skip to content

Commit 64e3809

Browse files
committedMar 15, 2024·
chore: update ruff version
1 parent dc7f415 commit 64e3809

20 files changed

+48
-70
lines changed
 

‎cors_webserver.py

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
can connect to the web server.
2424
"""
2525

26-
2726
import argparse
2827
import os
2928
import sys

‎python/README.md

+6-10
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Neuroglancer client if Python data sources are used.
2020

2121
It is recommended that you activate a suitable Python virtual environment before installing.
2222

23-
Python 3.5 or later is required.
23+
Python 3.9 or later is required.
2424

2525
You can install the latest published package from [PyPI](https://pypi.org/project/neuroglancer)
2626
with:
@@ -77,12 +77,12 @@ extension module.
7777
For normal installation, run the following from the root of the repository:
7878

7979
```shell
80-
python setup.py install
80+
pip install .
8181
```
8282

83-
That will automatically build the Neuroglancer client using Node.js if it has not already been built
84-
(i.e. if `neuroglancer/static/index.html` does not exist). To rebuild the Neuroglancer client
85-
explicitly, you can use:
83+
That will automatically build the Neuroglancer client using Node.js if it has
84+
not already been built (i.e. if `neuroglancer/static/client/index.html` does not
85+
exist). To rebuild the Neuroglancer client explicitly, you can use:
8686

8787
```shell
8888
python setup.py bundle_client
@@ -94,10 +94,6 @@ or
9494
npm run build-python
9595
```
9696

97-
Note: Installing from a local checkout using `pip install .` also works, but it may be slower
98-
because it makes a full copy of the local directory (https://github.com/pypa/pip/pull/7882),
99-
including the possibly-large `.git` and `node_modules` directories.
100-
10197
#### Editable installation (for development purposes)
10298

10399
During development, an *editable* installation allows the package to be imported directly from the
@@ -110,7 +106,7 @@ pip install -e .
110106
Any changes you make to the .py source files take effect the next time the package is imported,
111107
without the need to reinstall. If you make changes to the Neuroglancer client, you still need to
112108
rebuild it with `npm run build-python`. You can also keep the Neuroglancer client continuously
113-
up-to-date by running `npm run dev-server-python`.
109+
up-to-date by running `npm run build-python:watch`.
114110

115111
## Examples
116112

‎python/examples/extend_segments_tool.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env python2
22
"""Tool for extending via equivalences a set of segments."""
33

4-
54
import argparse
65
import copy
76
import os
@@ -182,9 +181,9 @@ def make_initial_state(self, segment_id, base_state):
182181
segments = self.get_state_segment_ids(state)
183182
segments.clear()
184183
segments[segment_id] = True
185-
state.layers[
186-
self.point_annotation_layer_name
187-
] = neuroglancer.PointAnnotationLayer()
184+
state.layers[self.point_annotation_layer_name] = (
185+
neuroglancer.PointAnnotationLayer()
186+
)
188187

189188
return state
190189

‎python/neuroglancer/dvid_credentials.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
# limitations under the License.
1414

1515
"""Module implements function for authentication of layers based on DVID.
16-
Here tokens are fetched from local locations like env vars etc."""
17-
16+
Here tokens are fetched from local locations like env vars etc."""
1817

1918
import logging
2019
import os

‎python/neuroglancer/futures.py

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
"""Various extensions to the concurrent.futures module."""
1616

17-
1817
import concurrent.futures
1918
import threading
2019

‎python/neuroglancer/json_wrappers.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414
"""Facilities for converting JSON <-> Python objects"""
1515

16-
1716
import copy
1817
import inspect
1918
import numbers

‎python/neuroglancer/skeleton.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ def encode(self, source):
5050
expected_shape
5151
):
5252
raise ValueError(
53-
"Expected attribute {!r} to have shape {!r}, but was: {!r}".format(
54-
name, expected_shape, attribute.shape
55-
)
53+
f"Expected attribute {name!r} to have shape {expected_shape!r}, but was: {attribute.shape!r}"
5654
)
5755
result.write(attribute.tobytes())
5856
return result.getvalue()

‎python/neuroglancer/tool/cube.py

+13-11
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,19 @@
5050
position[face_dim] += (
5151
(face_dir * 2 - 1) * cube_size / 2 / state.dimensions[face_dim].scale
5252
)
53-
state.layout.cross_sections[
54-
"%d_%d" % (face_dim, face_dir)
55-
] = neuroglancer.CrossSection(
56-
width=cube_size / canonical_scale,
57-
height=cube_size / canonical_scale,
58-
position=neuroglancer.LinkedPosition(link="relative", value=position),
59-
orientation=neuroglancer.LinkedOrientationState(
60-
link="unlinked",
61-
value=orientations[face_dim],
62-
),
63-
scale=neuroglancer.LinkedZoomFactor(link="unlinked", value=1),
53+
state.layout.cross_sections["%d_%d" % (face_dim, face_dir)] = (
54+
neuroglancer.CrossSection(
55+
width=cube_size / canonical_scale,
56+
height=cube_size / canonical_scale,
57+
position=neuroglancer.LinkedPosition(
58+
link="relative", value=position
59+
),
60+
orientation=neuroglancer.LinkedOrientationState(
61+
link="unlinked",
62+
value=orientations[face_dim],
63+
),
64+
scale=neuroglancer.LinkedZoomFactor(link="unlinked", value=1),
65+
)
6466
)
6567

6668
print(neuroglancer.to_url(state))

‎python/neuroglancer/tool/mask_tool.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -221,18 +221,18 @@ def __init__(self):
221221

222222
with viewer.config_state.txn() as s:
223223
s.input_event_bindings.data_view["bracketleft"] = "anno-decrease-block-size"
224-
s.input_event_bindings.data_view[
225-
"bracketright"
226-
] = "anno-increase-block-size"
224+
s.input_event_bindings.data_view["bracketright"] = (
225+
"anno-increase-block-size"
226+
)
227227
s.input_event_bindings.data_view["control+keys"] = "anno-save"
228228
s.input_event_bindings.data_view["control+mousedown0"] = "anno-mark-pre"
229-
s.input_event_bindings.data_view[
230-
"control+shift+mousedown0"
231-
] = "anno-unmark-pre"
229+
s.input_event_bindings.data_view["control+shift+mousedown0"] = (
230+
"anno-unmark-pre"
231+
)
232232
s.input_event_bindings.data_view["control+mousedown2"] = "anno-mark-post"
233-
s.input_event_bindings.data_view[
234-
"control+shift+mousedown2"
235-
] = "anno-unmark-post"
233+
s.input_event_bindings.data_view["control+shift+mousedown2"] = (
234+
"anno-unmark-post"
235+
)
236236

237237
self.cur_message = None
238238

‎python/neuroglancer/tool/merge_tool.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -224,17 +224,17 @@ def __init__(self, filename):
224224
s.input_event_bindings.data_view["pageup"] = "anno-prev-state"
225225
s.input_event_bindings.data_view["pagedown"] = "anno-next-state"
226226
s.input_event_bindings.data_view["bracketleft"] = "anno-decrease-block-size"
227-
s.input_event_bindings.data_view[
228-
"bracketright"
229-
] = "anno-increase-block-size"
227+
s.input_event_bindings.data_view["bracketright"] = (
228+
"anno-increase-block-size"
229+
)
230230
s.input_event_bindings.data_view["control+keys"] = "anno-save"
231231
s.input_event_bindings.data_view["control+keya"] = "anno-show-all"
232-
s.input_event_bindings.data_view[
233-
"control+mousedown0"
234-
] = "anno-mark-false-merge"
235-
s.input_event_bindings.data_view[
236-
"control+shift+mousedown0"
237-
] = "anno-unmark-false-merge"
232+
s.input_event_bindings.data_view["control+mousedown0"] = (
233+
"anno-mark-false-merge"
234+
)
235+
s.input_event_bindings.data_view["control+shift+mousedown0"] = (
236+
"anno-unmark-false-merge"
237+
)
238238

239239
viewer.shared_state.add_changed_callback(self.on_state_changed)
240240
self.cur_message = None

‎python/neuroglancer/tool/video_tool.py

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
- the width and height are based on the browser size.
5959
"""
6060

61-
6261
import argparse
6362
import bisect
6463
import copy

‎python/neuroglancer/viewer_state.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414
"""Wrappers for representing the Neuroglancer viewer state."""
1515

16-
1716
import collections
1817
import collections.abc
1918
import copy
@@ -1138,10 +1137,7 @@ def __setattr__(self, key, value):
11381137
return setattr(self.layer, key, value)
11391138

11401139
def __repr__(self):
1141-
return "ManagedLayer({},{})".format(
1142-
encode_json_for_repr(self.name),
1143-
encode_json_for_repr(self.to_json()),
1144-
)
1140+
return f"ManagedLayer({encode_json_for_repr(self.name)},{encode_json_for_repr(self.to_json())})"
11451141

11461142
def to_json(self):
11471143
r = self.layer.to_json()
@@ -1648,9 +1644,9 @@ class ViewerState(JsonObjectWrapper):
16481644
projection_depth = projectionDepth = wrapped_property(
16491645
"projectionDepth", optional(float)
16501646
)
1651-
projection_orientation = (
1652-
projectionOrientation
1653-
) = perspectiveOrientation = perspective_orientation = wrapped_property(
1647+
projection_orientation = projectionOrientation = perspectiveOrientation = (
1648+
perspective_orientation
1649+
) = wrapped_property(
16541650
"projectionOrientation", optional(array_wrapper(np.float32, 4))
16551651
)
16561652
show_slices = showSlices = wrapped_property("showSlices", optional(bool, True))

‎python/requirements-lint.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ruff
1+
ruff==0.3.2

‎python/tests/context_lost_test.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414
"""Tests WebGL context lose/restore handling."""
1515

16-
1716
import neuroglancer
1817
import numpy as np
1918

‎python/tests/equivalence_map_test.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414
"""Tests for equivalence_map.py"""
1515

16-
1716
from neuroglancer import equivalence_map
1817

1918

‎python/tests/linked_segment_group_test.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414
"""Tests for linked_segmentation_{,color}group."""
1515

16-
1716
import neuroglancer
1817
import numpy as np
1918

‎python/tests/merge_tool_test.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414
"""Tests for merge_tool.py"""
1515

16-
1716
from neuroglancer.tool import merge_tool
1817

1918

‎python/tests/segment_colors_test.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414
"""Tests for segment_colors and segment_default_color."""
1515

16-
1716
import neuroglancer
1817
import numpy as np
1918
from neuroglancer.segment_colors import hash_function, hex_string_from_segment_id

‎setup.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,7 @@ def run(self):
223223
html_path = os.path.join(output_dir, "index.html")
224224
if os.path.exists(html_path):
225225
print(
226-
"Skipping rebuild of client bundle since {} already exists".format(
227-
html_path
228-
)
226+
f"Skipping rebuild of client bundle since {html_path} already exists"
229227
)
230228
return
231229

‎src/mesh/draco/build_wasm.py

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
`Dockerfile`).
1010
"""
1111

12-
1312
import pathlib
1413
import re
1514
import subprocess

0 commit comments

Comments
 (0)
Please sign in to comment.