Skip to content

Commit dc326e7

Browse files
authored
Merge pull request #261 from dstansby/pcr
Update pre-commit
2 parents fd47be0 + 312d50c commit dc326e7

File tree

6 files changed

+57
-38
lines changed

6 files changed

+57
-38
lines changed

Diff for: .github/workflows/docs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
sudo apt install graphviz --yes
3333
3434
- name: Build Docs
35-
uses: aganders3/headless-gui@v1
35+
uses: aganders3/headless-gui@v2
3636
with:
3737
run: make html
3838
working-directory: ./docs

Diff for: .github/workflows/napari_hub_preview.yml

-21
This file was deleted.

Diff for: .github/workflows/test_and_deploy.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,16 @@ jobs:
5858
if: ${{ always() }}
5959

6060
- name: Coverage
61-
uses: codecov/codecov-action@v3
61+
uses: codecov/codecov-action@v4
6262
# Don't run coverage on merge queue CI to avoid duplicating reports
6363
# to codecov. See https://github.com/matplotlib/napari-matplotlib/issues/155
6464
if: github.event_name != 'merge_group'
6565
with:
6666
token: ${{ secrets.CODECOV_TOKEN }}
6767
fail_ci_if_error: true
6868

69+
70+
6971
deploy:
7072
# this will run when you have tagged a commit, starting with "v*"
7173
# and requires that you have put your twine API key in your

Diff for: .pre-commit-config.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.5.0
3+
rev: v4.6.0
44
hooks:
55
- id: check-docstring-first
66
- id: end-of-file-fixer
77
- id: trailing-whitespace
88

99
- repo: https://github.com/psf/black
10-
rev: 24.2.0
10+
rev: 24.4.2
1111
hooks:
1212
- id: black
1313

@@ -17,14 +17,14 @@ repos:
1717
- id: napari-plugin-checks
1818

1919
- repo: https://github.com/pre-commit/mirrors-mypy
20-
rev: v1.8.0
20+
rev: v1.10.0
2121
hooks:
2222
- id: mypy
2323
additional_dependencies: [numpy, matplotlib]
2424

2525
- repo: https://github.com/astral-sh/ruff-pre-commit
2626
# Ruff version.
27-
rev: 'v0.2.2'
27+
rev: 'v0.4.2'
2828
hooks:
2929
- id: ruff
3030

Diff for: docs/conf.py

+48-9
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# import os
1414
# import sys
1515
# sys.path.insert(0, os.path.abspath('.'))
16-
import qtgallery
16+
from sphinx_gallery import scrapers
1717

1818
# -- Project information -----------------------------------------------------
1919

@@ -35,18 +35,57 @@
3535
"sphinx.ext.intersphinx",
3636
]
3737

38+
39+
def reset_napari(gallery_conf, fname): # type: ignore[no-untyped-def]
40+
from napari.settings import get_settings
41+
from qtpy.QtWidgets import QApplication
42+
43+
settings = get_settings()
44+
settings.appearance.theme = "dark"
45+
46+
# Disabling `QApplication.exec_` means example scripts can call `exec_`
47+
# (scripts work when run normally) without blocking example execution by
48+
# sphinx-gallery. (from qtgallery)
49+
QApplication.exec_ = lambda _: None
50+
51+
52+
def napari_scraper(block, block_vars, gallery_conf): # type: ignore[no-untyped-def]
53+
"""Basic napari window scraper.
54+
55+
Looks for any QtMainWindow instances and takes a screenshot of them.
56+
57+
`app.processEvents()` allows Qt events to propagateo and prevents hanging.
58+
"""
59+
import napari
60+
61+
imgpath_iter = block_vars["image_path_iterator"]
62+
63+
if app := napari.qt.get_app():
64+
app.processEvents()
65+
else:
66+
return ""
67+
68+
img_paths = []
69+
for win, img_path in zip(
70+
reversed(napari._qt.qt_main_window._QtMainWindow._instances),
71+
imgpath_iter,
72+
):
73+
img_paths.append(img_path)
74+
win._window.screenshot(img_path, canvas_only=False)
75+
76+
napari.Viewer.close_all()
77+
app.processEvents()
78+
79+
return scrapers.figure_rst(img_paths, gallery_conf["src_dir"])
80+
81+
3882
sphinx_gallery_conf = {
3983
"filename_pattern": ".",
40-
"image_scrapers": (qtgallery.qtscraper,),
41-
"reset_modules": (qtgallery.reset_qapp,),
84+
"image_scrapers": (napari_scraper,),
85+
"reset_modules": (reset_napari,),
4286
}
87+
suppress_warnings = ["config.cache"]
4388

44-
qtgallery_conf = {
45-
"xvfb_size": (640, 480),
46-
"xvfb_color_depth": 24,
47-
"xfvb_use_xauth": False,
48-
"xfvb_extra_args": [],
49-
}
5089

5190
numpydoc_show_class_members = False
5291
automodapi_inheritance_diagram = True

Diff for: setup.cfg

+1-2
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,10 @@ napari.manifest =
4747

4848
[options.extras_require]
4949
docs =
50-
napari[all]==0.4.19rc3
50+
napari[all]
5151
numpydoc
5252
pydantic<2
5353
pydata-sphinx-theme
54-
qtgallery
5554
sphinx
5655
sphinx-automodapi
5756
sphinx-gallery

0 commit comments

Comments
 (0)