Skip to content

Some more repo-review suggestions #264

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 1 commit into from
May 25, 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 .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/psf/black
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.4.2
hooks:
- id: black
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def napari_scraper(block, block_vars, gallery_conf): # type: ignore[no-untyped-
for win, img_path in zip(
reversed(napari._qt.qt_main_window._QtMainWindow._instances),
imgpath_iter,
strict=False,
):
img_paths.append(img_path)
win._window.screenshot(img_path, canvas_only=False)
Expand Down
12 changes: 8 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ line_length = 79

[tool.ruff]
target-version = "py310"
select = ["I", "UP", "F", "E", "W", "D"]
fix = true

[tool.ruff.lint]
select = ["B", "I", "UP", "F", "E", "W", "D"]
ignore = [
"D100", # Missing docstring in public module
"D104", # Missing docstring in public package
Expand All @@ -41,14 +44,13 @@ ignore = [
"D401", # First line of docstring should be in imperative mood

]
fix = true

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"docs/*" = ["D"]
"examples/*" = ["D"]
"src/napari_matplotlib/tests/*" = ["D"]

[tool.ruff.pydocstyle]
[tool.ruff.lint.pydocstyle]
convention = "numpy"

[tool.mypy]
Expand All @@ -59,6 +61,8 @@ disallow_subclassing_any = false # TODO: fix
warn_return_any = false # TODO: fix
ignore_missing_imports = true

enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]

[[tool.mypy.overrides]]
module = [
"napari_matplotlib/tests/*",
Expand Down
2 changes: 1 addition & 1 deletion src/napari_matplotlib/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def on_update_layers(self) -> None:

def _update_contrast_lims(self) -> None:
for lim, line in zip(
self.layers[0].contrast_limits, self._contrast_lines
self.layers[0].contrast_limits, self._contrast_lines, strict=False
):
line.set_xdata(lim)

Expand Down
2 changes: 1 addition & 1 deletion src/napari_matplotlib/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_interval():
assert 10 not in interval

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

with pytest.raises(ValueError, match="must be <= upper_bound"):
Interval(5, 3)
Expand Down
9 changes: 7 additions & 2 deletions src/napari_matplotlib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,18 @@ def _get_dimension(nodes: list[tinycss2.ast.Node], id_name: str) -> int | None:
None if no IdentToken is found.
"""
cleaned_nodes = [node for node in nodes if node.type != "whitespace"]
for name, _, value, _ in zip(*(iter(cleaned_nodes),) * 4):
for name, _, value, _ in zip(*(iter(cleaned_nodes),) * 4, strict=False):
if (
name.type == "ident"
and value.type == "dimension"
and name.value == id_name
):
return value.int_value
warn(f"Unable to find DimensionToken for {id_name}", RuntimeWarning)
warn(
f"Unable to find DimensionToken for {id_name}",
RuntimeWarning,
stacklevel=1,
)
return None


Expand Down Expand Up @@ -134,6 +138,7 @@ def from_napari_css_get_size_of(
f"Unable to find {qt_element_name} or unable to find its size in "
f"the current Napari stylesheet, falling back to {fallback}",
RuntimeWarning,
stacklevel=1,
)
return QSize(*fallback)

Expand Down
Loading