Skip to content

Commit 33a71d3

Browse files
committed
Some more repo-review suggestions
1 parent 9a1147c commit 33a71d3

File tree

6 files changed

+19
-9
lines changed

6 files changed

+19
-9
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ repos:
66
- id: end-of-file-fixer
77
- id: trailing-whitespace
88

9-
- repo: https://github.com/psf/black
9+
- repo: https://github.com/psf/black-pre-commit-mirror
1010
rev: 24.4.2
1111
hooks:
1212
- id: black

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def napari_scraper(block, block_vars, gallery_conf): # type: ignore[no-untyped-
6969
for win, img_path in zip(
7070
reversed(napari._qt.qt_main_window._QtMainWindow._instances),
7171
imgpath_iter,
72+
strict=False,
7273
):
7374
img_paths.append(img_path)
7475
win._window.screenshot(img_path, canvas_only=False)

pyproject.toml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ line_length = 79
3131

3232
[tool.ruff]
3333
target-version = "py310"
34-
select = ["I", "UP", "F", "E", "W", "D"]
34+
fix = true
35+
36+
[tool.ruff.lint]
37+
select = ["B", "I", "UP", "F", "E", "W", "D"]
3538
ignore = [
3639
"D100", # Missing docstring in public module
3740
"D104", # Missing docstring in public package
@@ -41,14 +44,13 @@ ignore = [
4144
"D401", # First line of docstring should be in imperative mood
4245

4346
]
44-
fix = true
4547

46-
[tool.ruff.per-file-ignores]
48+
[tool.ruff.lint.per-file-ignores]
4749
"docs/*" = ["D"]
4850
"examples/*" = ["D"]
4951
"src/napari_matplotlib/tests/*" = ["D"]
5052

51-
[tool.ruff.pydocstyle]
53+
[tool.ruff.lint.pydocstyle]
5254
convention = "numpy"
5355

5456
[tool.mypy]
@@ -59,6 +61,8 @@ disallow_subclassing_any = false # TODO: fix
5961
warn_return_any = false # TODO: fix
6062
ignore_missing_imports = true
6163

64+
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
65+
6266
[[tool.mypy.overrides]]
6367
module = [
6468
"napari_matplotlib/tests/*",

src/napari_matplotlib/histogram.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def on_update_layers(self) -> None:
6060

6161
def _update_contrast_lims(self) -> None:
6262
for lim, line in zip(
63-
self.layers[0].contrast_limits, self._contrast_lines
63+
self.layers[0].contrast_limits, self._contrast_lines, strict=False
6464
):
6565
line.set_xdata(lim)
6666

src/napari_matplotlib/tests/test_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_interval():
2626
assert 10 not in interval
2727

2828
with pytest.raises(ValueError, match="must be an integer"):
29-
"string" in interval # type: ignore
29+
assert "string" in interval # type: ignore[operator]
3030

3131
with pytest.raises(ValueError, match="must be <= upper_bound"):
3232
Interval(5, 3)

src/napari_matplotlib/util.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,18 @@ def _get_dimension(nodes: list[tinycss2.ast.Node], id_name: str) -> int | None:
9494
None if no IdentToken is found.
9595
"""
9696
cleaned_nodes = [node for node in nodes if node.type != "whitespace"]
97-
for name, _, value, _ in zip(*(iter(cleaned_nodes),) * 4):
97+
for name, _, value, _ in zip(*(iter(cleaned_nodes),) * 4, strict=False):
9898
if (
9999
name.type == "ident"
100100
and value.type == "dimension"
101101
and name.value == id_name
102102
):
103103
return value.int_value
104-
warn(f"Unable to find DimensionToken for {id_name}", RuntimeWarning)
104+
warn(
105+
f"Unable to find DimensionToken for {id_name}",
106+
RuntimeWarning,
107+
stacklevel=1,
108+
)
105109
return None
106110

107111

@@ -134,6 +138,7 @@ def from_napari_css_get_size_of(
134138
f"Unable to find {qt_element_name} or unable to find its size in "
135139
f"the current Napari stylesheet, falling back to {fallback}",
136140
RuntimeWarning,
141+
stacklevel=1,
137142
)
138143
return QSize(*fallback)
139144

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy