Skip to content

Commit

Permalink
chore: update ruff version
Browse files Browse the repository at this point in the history
  • Loading branch information
jbms committed Mar 15, 2024
1 parent c354a02 commit ff21018
Show file tree
Hide file tree
Showing 20 changed files with 48 additions and 70 deletions.
1 change: 0 additions & 1 deletion cors_webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
can connect to the web server.
"""


import argparse
import os
import sys
Expand Down
16 changes: 6 additions & 10 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Neuroglancer client if Python data sources are used.

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

Python 3.5 or later is required.
Python 3.9 or later is required.

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

```shell
python setup.py install
pip install .
```

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

```shell
python setup.py bundle_client
Expand All @@ -94,10 +94,6 @@ or
npm run build-python
```

Note: Installing from a local checkout using `pip install .` also works, but it may be slower
because it makes a full copy of the local directory (https://github.com/pypa/pip/pull/7882),
including the possibly-large `.git` and `node_modules` directories.

#### Editable installation (for development purposes)

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

## Examples

Expand Down
7 changes: 3 additions & 4 deletions python/examples/extend_segments_tool.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python2
"""Tool for extending via equivalences a set of segments."""


import argparse
import copy
import os
Expand Down Expand Up @@ -182,9 +181,9 @@ def make_initial_state(self, segment_id, base_state):
segments = self.get_state_segment_ids(state)
segments.clear()
segments[segment_id] = True
state.layers[
self.point_annotation_layer_name
] = neuroglancer.PointAnnotationLayer()
state.layers[self.point_annotation_layer_name] = (
neuroglancer.PointAnnotationLayer()
)

return state

Expand Down
3 changes: 1 addition & 2 deletions python/neuroglancer/dvid_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
# limitations under the License.

"""Module implements function for authentication of layers based on DVID.
Here tokens are fetched from local locations like env vars etc."""

Here tokens are fetched from local locations like env vars etc."""

import logging
import os
Expand Down
1 change: 0 additions & 1 deletion python/neuroglancer/futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

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


import concurrent.futures
import threading

Expand Down
1 change: 0 additions & 1 deletion python/neuroglancer/json_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.
"""Facilities for converting JSON <-> Python objects"""


import copy
import inspect
import numbers
Expand Down
4 changes: 1 addition & 3 deletions python/neuroglancer/skeleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ def encode(self, source):
expected_shape
):
raise ValueError(
"Expected attribute {!r} to have shape {!r}, but was: {!r}".format(
name, expected_shape, attribute.shape
)
f"Expected attribute {name!r} to have shape {expected_shape!r}, but was: {attribute.shape!r}"
)
result.write(attribute.tobytes())
return result.getvalue()
Expand Down
24 changes: 13 additions & 11 deletions python/neuroglancer/tool/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,19 @@
position[face_dim] += (
(face_dir * 2 - 1) * cube_size / 2 / state.dimensions[face_dim].scale
)
state.layout.cross_sections[
"%d_%d" % (face_dim, face_dir)
] = neuroglancer.CrossSection(
width=cube_size / canonical_scale,
height=cube_size / canonical_scale,
position=neuroglancer.LinkedPosition(link="relative", value=position),
orientation=neuroglancer.LinkedOrientationState(
link="unlinked",
value=orientations[face_dim],
),
scale=neuroglancer.LinkedZoomFactor(link="unlinked", value=1),
state.layout.cross_sections["%d_%d" % (face_dim, face_dir)] = (
neuroglancer.CrossSection(
width=cube_size / canonical_scale,
height=cube_size / canonical_scale,
position=neuroglancer.LinkedPosition(
link="relative", value=position
),
orientation=neuroglancer.LinkedOrientationState(
link="unlinked",
value=orientations[face_dim],
),
scale=neuroglancer.LinkedZoomFactor(link="unlinked", value=1),
)
)

print(neuroglancer.to_url(state))
18 changes: 9 additions & 9 deletions python/neuroglancer/tool/mask_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,18 +221,18 @@ def __init__(self):

with viewer.config_state.txn() as s:
s.input_event_bindings.data_view["bracketleft"] = "anno-decrease-block-size"
s.input_event_bindings.data_view[
"bracketright"
] = "anno-increase-block-size"
s.input_event_bindings.data_view["bracketright"] = (
"anno-increase-block-size"
)
s.input_event_bindings.data_view["control+keys"] = "anno-save"
s.input_event_bindings.data_view["control+mousedown0"] = "anno-mark-pre"
s.input_event_bindings.data_view[
"control+shift+mousedown0"
] = "anno-unmark-pre"
s.input_event_bindings.data_view["control+shift+mousedown0"] = (
"anno-unmark-pre"
)
s.input_event_bindings.data_view["control+mousedown2"] = "anno-mark-post"
s.input_event_bindings.data_view[
"control+shift+mousedown2"
] = "anno-unmark-post"
s.input_event_bindings.data_view["control+shift+mousedown2"] = (
"anno-unmark-post"
)

self.cur_message = None

Expand Down
18 changes: 9 additions & 9 deletions python/neuroglancer/tool/merge_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,17 @@ def __init__(self, filename):
s.input_event_bindings.data_view["pageup"] = "anno-prev-state"
s.input_event_bindings.data_view["pagedown"] = "anno-next-state"
s.input_event_bindings.data_view["bracketleft"] = "anno-decrease-block-size"
s.input_event_bindings.data_view[
"bracketright"
] = "anno-increase-block-size"
s.input_event_bindings.data_view["bracketright"] = (
"anno-increase-block-size"
)
s.input_event_bindings.data_view["control+keys"] = "anno-save"
s.input_event_bindings.data_view["control+keya"] = "anno-show-all"
s.input_event_bindings.data_view[
"control+mousedown0"
] = "anno-mark-false-merge"
s.input_event_bindings.data_view[
"control+shift+mousedown0"
] = "anno-unmark-false-merge"
s.input_event_bindings.data_view["control+mousedown0"] = (
"anno-mark-false-merge"
)
s.input_event_bindings.data_view["control+shift+mousedown0"] = (
"anno-unmark-false-merge"
)

viewer.shared_state.add_changed_callback(self.on_state_changed)
self.cur_message = None
Expand Down
1 change: 0 additions & 1 deletion python/neuroglancer/tool/video_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
- the width and height are based on the browser size.
"""


import argparse
import bisect
import copy
Expand Down
12 changes: 4 additions & 8 deletions python/neuroglancer/viewer_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.
"""Wrappers for representing the Neuroglancer viewer state."""


import collections
import collections.abc
import copy
Expand Down Expand Up @@ -1138,10 +1137,7 @@ def __setattr__(self, key, value):
return setattr(self.layer, key, value)

def __repr__(self):
return "ManagedLayer({},{})".format(
encode_json_for_repr(self.name),
encode_json_for_repr(self.to_json()),
)
return f"ManagedLayer({encode_json_for_repr(self.name)},{encode_json_for_repr(self.to_json())})"

def to_json(self):
r = self.layer.to_json()
Expand Down Expand Up @@ -1648,9 +1644,9 @@ class ViewerState(JsonObjectWrapper):
projection_depth = projectionDepth = wrapped_property(
"projectionDepth", optional(float)
)
projection_orientation = (
projectionOrientation
) = perspectiveOrientation = perspective_orientation = wrapped_property(
projection_orientation = projectionOrientation = perspectiveOrientation = (
perspective_orientation
) = wrapped_property(
"projectionOrientation", optional(array_wrapper(np.float32, 4))
)
show_slices = showSlices = wrapped_property("showSlices", optional(bool, True))
Expand Down
2 changes: 1 addition & 1 deletion python/requirements-lint.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruff
ruff==0.3.2
1 change: 0 additions & 1 deletion python/tests/context_lost_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.
"""Tests WebGL context lose/restore handling."""


import neuroglancer
import numpy as np

Expand Down
1 change: 0 additions & 1 deletion python/tests/equivalence_map_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.
"""Tests for equivalence_map.py"""


from neuroglancer import equivalence_map


Expand Down
1 change: 0 additions & 1 deletion python/tests/linked_segment_group_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.
"""Tests for linked_segmentation_{,color}group."""


import neuroglancer
import numpy as np

Expand Down
1 change: 0 additions & 1 deletion python/tests/merge_tool_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.
"""Tests for merge_tool.py"""


from neuroglancer.tool import merge_tool


Expand Down
1 change: 0 additions & 1 deletion python/tests/segment_colors_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.
"""Tests for segment_colors and segment_default_color."""


import neuroglancer
import numpy as np
from neuroglancer.segment_colors import hash_function, hex_string_from_segment_id
Expand Down
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,7 @@ def run(self):
html_path = os.path.join(output_dir, "index.html")
if os.path.exists(html_path):
print(
"Skipping rebuild of client bundle since {} already exists".format(
html_path
)
f"Skipping rebuild of client bundle since {html_path} already exists"
)
return

Expand Down
1 change: 0 additions & 1 deletion src/mesh/draco/build_wasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
`Dockerfile`).
"""


import pathlib
import re
import subprocess
Expand Down

0 comments on commit ff21018

Please sign in to comment.