Skip to content

Update pre-commit #261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 24, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
sudo apt install graphviz --yes

- name: Build Docs
uses: aganders3/headless-gui@v1
uses: aganders3/headless-gui@v2
with:
run: make html
working-directory: ./docs
Expand Down
21 changes: 0 additions & 21 deletions .github/workflows/napari_hub_preview.yml

This file was deleted.

4 changes: 3 additions & 1 deletion .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,16 @@ jobs:
if: ${{ always() }}

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



deploy:
# this will run when you have tagged a commit, starting with "v*"
# and requires that you have put your twine API key in your
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-docstring-first
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/psf/black
rev: 24.2.0
rev: 24.4.2
hooks:
- id: black

Expand All @@ -17,14 +17,14 @@ repos:
- id: napari-plugin-checks

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
rev: v1.10.0
hooks:
- id: mypy
additional_dependencies: [numpy, matplotlib]

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: 'v0.2.2'
rev: 'v0.4.2'
hooks:
- id: ruff

Expand Down
57 changes: 48 additions & 9 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
import qtgallery
from sphinx_gallery import scrapers

# -- Project information -----------------------------------------------------

Expand All @@ -35,18 +35,57 @@
"sphinx.ext.intersphinx",
]


def reset_napari(gallery_conf, fname): # type: ignore[no-untyped-def]
from napari.settings import get_settings
from qtpy.QtWidgets import QApplication

settings = get_settings()
settings.appearance.theme = "dark"

# Disabling `QApplication.exec_` means example scripts can call `exec_`
# (scripts work when run normally) without blocking example execution by
# sphinx-gallery. (from qtgallery)
QApplication.exec_ = lambda _: None


def napari_scraper(block, block_vars, gallery_conf): # type: ignore[no-untyped-def]
"""Basic napari window scraper.

Looks for any QtMainWindow instances and takes a screenshot of them.

`app.processEvents()` allows Qt events to propagateo and prevents hanging.
"""
import napari

imgpath_iter = block_vars["image_path_iterator"]

if app := napari.qt.get_app():
app.processEvents()
else:
return ""

img_paths = []
for win, img_path in zip(
reversed(napari._qt.qt_main_window._QtMainWindow._instances),
imgpath_iter,
):
img_paths.append(img_path)
win._window.screenshot(img_path, canvas_only=False)

napari.Viewer.close_all()
app.processEvents()

return scrapers.figure_rst(img_paths, gallery_conf["src_dir"])


sphinx_gallery_conf = {
"filename_pattern": ".",
"image_scrapers": (qtgallery.qtscraper,),
"reset_modules": (qtgallery.reset_qapp,),
"image_scrapers": (napari_scraper,),
"reset_modules": (reset_napari,),
}
suppress_warnings = ["config.cache"]

qtgallery_conf = {
"xvfb_size": (640, 480),
"xvfb_color_depth": 24,
"xfvb_use_xauth": False,
"xfvb_extra_args": [],
}

numpydoc_show_class_members = False
automodapi_inheritance_diagram = True
Expand Down
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ napari.manifest =

[options.extras_require]
docs =
napari[all]==0.4.19rc3
napari[all]
numpydoc
pydantic<2
pydata-sphinx-theme
qtgallery
sphinx
sphinx-automodapi
sphinx-gallery
Expand Down
Loading