Skip to content

Commit

Permalink
Replace flake8, isort and pyupgrade by ruff, enable additional useful…
Browse files Browse the repository at this point in the history
…l rules (napari#5513)

Co-authored-by: Lorenzo Gaifas <[email protected]>
Co-authored-by: Matthias Bussonnier <[email protected]>
  • Loading branch information
3 people authored Jan 31, 2023
1 parent ca97562 commit 4b71b83
Show file tree
Hide file tree
Showing 353 changed files with 801 additions and 726 deletions.
21 changes: 1 addition & 20 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,17 @@ repos:
rev: v2.1.3
hooks:
- id: pycln
- repo: https://github.com/pycqa/isort
rev: 5.11.4
hooks:
- id: isort
exclude: _vendor|vendored|examples
- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black
pass_filenames: true
exclude: _vendor|vendored|examples
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.230
rev: v0.0.235
hooks:
- id: ruff
exclude: _vendor|vendored
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
additional_dependencies: [flake8-typing-imports]
pass_filenames: true
# this seems to need to be here in addition to setup.cfg
exclude: _vendor|vendored|__init__.py|examples
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args: ["--py38-plus", "--keep-runtime-typing"]
exclude: _vendor|vendored|examples
- repo: https://github.com/seddonym/import-linter
rev: v1.6.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion examples/3D_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

import numpy as np
from skimage import data
import napari

import napari

blobs = data.binary_blobs(
length=128, blob_size_fraction=0.05, n_dim=3, volume_fraction=0.05
Expand Down
5 changes: 3 additions & 2 deletions examples/3Dimage_plane_rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
.. tags:: visualization-advanced, gui, layers
"""
import napari
import numpy as np
from napari.utils.translations import trans
from skimage import data

import napari
from napari.utils.translations import trans

viewer = napari.Viewer(ndisplay=3)

# add a 3D image
Expand Down
8 changes: 5 additions & 3 deletions examples/3d_kymograph_.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
.. tags:: experimental
"""
from itertools import product

import numpy as np
import napari
from tqdm import tqdm
from itertools import product

import napari

try:
from omero.gateway import BlitzGateway
Expand Down Expand Up @@ -157,4 +159,4 @@ def IDR_fetch_image(image_id: int, progressbar: bool = True) -> np.ndarray:
v.camera.angles = (-20, 23, -50)
v.camera.zoom = 0.17

napari.run()
napari.run()
4 changes: 2 additions & 2 deletions examples/add-points-3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
.. tags:: visualization-nD
"""

from skimage import data
from scipy import ndimage as ndi
import napari
from skimage import data

import napari

blobs = data.binary_blobs(
length=128, volume_fraction=0.1, n_dim=3
Expand Down
2 changes: 1 addition & 1 deletion examples/add_3D_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"""

from skimage import data
import napari

import napari

blobs = data.binary_blobs(length=64, volume_fraction=0.1, n_dim=3).astype(
float
Expand Down
4 changes: 2 additions & 2 deletions examples/add_grayscale_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
.. tags:: visualization-basic
"""

from skimage import data
import napari
import numpy as np
from skimage import data

import napari

# simulating a grayscale image here for testing contrast limits adjustments
image = data.astronaut().mean(-1) * 100 + 100
Expand Down
1 change: 1 addition & 0 deletions examples/add_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""

from skimage import data

import napari

# create the viewer with an image
Expand Down
1 change: 1 addition & 0 deletions examples/add_image_transformed.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""

from skimage import data

import napari

# create the viewer with an image and transform (rotate) it
Expand Down
6 changes: 3 additions & 3 deletions examples/add_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

from skimage import data
from skimage.filters import threshold_otsu
from skimage.segmentation import clear_border
from skimage.measure import label
from skimage.morphology import closing, square, remove_small_objects
import napari
from skimage.morphology import closing, remove_small_objects, square
from skimage.segmentation import clear_border

import napari

image = data.coins()[50:-50, 50:-50]

Expand Down
8 changes: 4 additions & 4 deletions examples/add_labels_with_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
"""


import numpy as np
from skimage import data
from skimage.filters import threshold_otsu
from skimage.segmentation import clear_border
from skimage.measure import label
from skimage.morphology import closing, square, remove_small_objects
import numpy as np
import napari
from skimage.morphology import closing, remove_small_objects, square
from skimage.segmentation import clear_border

import napari

image = data.coins()[50:-50, 50:-50]

Expand Down
4 changes: 2 additions & 2 deletions examples/add_multiscale_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
.. tags:: visualization-advanced
"""

import numpy as np
from skimage import data
from skimage.transform import pyramid_gaussian
import napari
import numpy as np

import napari

# create multiscale from astronaut image
base = np.tile(data.astronaut(), (8, 8, 1))
Expand Down
2 changes: 1 addition & 1 deletion examples/add_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import numpy as np
from skimage import data
from skimage.color import rgb2gray
import napari

import napari

# add the image
viewer = napari.view_image(rgb2gray(data.astronaut()))
Expand Down
3 changes: 2 additions & 1 deletion examples/add_points_on_nD_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
.. tags:: visualization-nD
"""

import napari
import numpy as np

import napari

# Create rectangles in 4D
data = [
[
Expand Down
2 changes: 1 addition & 1 deletion examples/add_points_with_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import numpy as np
from skimage import data
from skimage.color import rgb2gray
import napari

import napari

# add the image
viewer = napari.view_image(rgb2gray(data.astronaut()))
Expand Down
1 change: 1 addition & 0 deletions examples/add_points_with_multicolor_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""

import numpy as np

import napari

# add the image with three points
Expand Down
2 changes: 1 addition & 1 deletion examples/add_points_with_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"""

import numpy as np
import napari

import napari

# add the image
viewer = napari.view_image(np.zeros((400, 400)))
Expand Down
2 changes: 1 addition & 1 deletion examples/add_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

import numpy as np
from skimage import data
import napari

import napari

# add the image
viewer = napari.view_image(data.camera(), name='photographer')
Expand Down
2 changes: 1 addition & 1 deletion examples/add_shapes_with_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

import numpy as np
from skimage import data
import napari

import napari

# add the image
viewer = napari.view_image(data.camera(), name='photographer')
Expand Down
2 changes: 1 addition & 1 deletion examples/add_shapes_with_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

import numpy as np
from skimage import data
import napari

import napari

# add the image
viewer = napari.view_image(data.camera(), name='photographer')
Expand Down
2 changes: 1 addition & 1 deletion examples/add_surface_2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"""

import numpy as np
import napari

import napari

data = np.array([[0, 0], [0, 20], [10, 0], [10, 10]])
faces = np.array([[0, 1, 2], [1, 2, 3]])
Expand Down
4 changes: 2 additions & 2 deletions examples/add_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
.. tags:: visualization-basic
"""

import napari
from skimage import data
import numpy as np
from skimage import data

import napari

# create the viewer and window
viewer = napari.Viewer()
Expand Down
4 changes: 2 additions & 2 deletions examples/add_vectors_color_by_angle.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
.. tags:: visualization-advanced
"""

import napari
from skimage import data
import numpy as np
from skimage import data

import napari

# create the viewer and window
viewer = napari.Viewer()
Expand Down
2 changes: 1 addition & 1 deletion examples/add_vectors_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
.. tags:: visualization-basic
"""

import napari
import numpy as np

import napari

# create the viewer and window
viewer = napari.Viewer()
Expand Down
3 changes: 2 additions & 1 deletion examples/affine_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
.. tags:: visualization-advanced
"""
import numpy as np
import napari
import scipy.ndimage as ndi

import napari

# Create a random image
image = np.random.random((5, 5))

Expand Down
2 changes: 1 addition & 1 deletion examples/annotate-2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

import numpy as np
from skimage import data
import napari

import napari

print("click to add points; close the window when finished.")

Expand Down
5 changes: 3 additions & 2 deletions examples/annotate_segmentation_with_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
import numpy as np
from skimage import data
from skimage.filters import threshold_otsu
from skimage.segmentation import clear_border
from skimage.measure import label, regionprops_table
from skimage.morphology import closing, square, remove_small_objects
from skimage.morphology import closing, remove_small_objects, square
from skimage.segmentation import clear_border

import napari


Expand Down
4 changes: 2 additions & 2 deletions examples/bbox_annotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
.. tags:: gui
"""

from magicgui.widgets import ComboBox, Container
import napari
import numpy as np
import pandas as pd
from magicgui.widgets import ComboBox, Container
from skimage import data

import napari

# set up the categorical annotation values and text display properties
box_annotations = ['person', 'sky', 'camera']
Expand Down
5 changes: 3 additions & 2 deletions examples/clipboard_.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
.. tags:: gui
"""

from qtpy.QtWidgets import QPushButton, QVBoxLayout, QWidget
from skimage import data
from qtpy.QtWidgets import QVBoxLayout, QPushButton, QWidget

import napari

# create the viewer with an image
viewer = napari.view_image(data.moon())

class Grabber(QWidget):
def __init__(self):
def __init__(self) -> None:
super().__init__()

self.copy_canvas_btn = QPushButton("Copy Canvas to Clipboard", self)
Expand Down
5 changes: 3 additions & 2 deletions examples/clipping_planes_interactive_.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
.. tags:: experimental
"""
import napari
import numpy as np
from skimage import data
from scipy import ndimage
from skimage import data
from vispy.geometry import create_sphere

import napari

viewer = napari.Viewer(ndisplay=3)

# VOLUME and LABELS
Expand Down
Loading

0 comments on commit 4b71b83

Please sign in to comment.