Skip to content

ruff fixes #196

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 45 commits into from
Sep 2, 2024
Merged
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
23bf98e
ruff fixes
DanielYang59 Sep 1, 2024
2a9ac7e
fix s101 use of assert
DanielYang59 Sep 1, 2024
3009cb4
globally ignore SLF001, access private class member
DanielYang59 Sep 1, 2024
aa69640
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 1, 2024
10829ce
add todo tag
DanielYang59 Sep 1, 2024
2d1ecbb
put docstring and global ignore on top
DanielYang59 Sep 1, 2024
f25d6b9
Merge branch 'ruff-pmv' of github.com:janosh/pymatviz into ruff-pmv
DanielYang59 Sep 1, 2024
920303a
fix py017, properly capture exception
DanielYang59 Sep 1, 2024
f6f3057
Fix PT011, exception capture without match
DanielYang59 Sep 1, 2024
31e8364
add TODO tag for https://github.com/janosh/pymatviz/pull/195#issuecom…
DanielYang59 Sep 1, 2024
49809a1
fix NPY201, np trapz
DanielYang59 Sep 1, 2024
337eb12
use warn over print to fix T201
DanielYang59 Sep 1, 2024
46b2400
add comments for globally ignored ruff rules
DanielYang59 Sep 1, 2024
90eb61a
guard type check only import when possible
DanielYang59 Sep 1, 2024
0ccfd1b
remove ISC001 from ignore
DanielYang59 Sep 1, 2024
c6b7245
add todo tag
DanielYang59 Sep 1, 2024
d5c91b8
reduce duration items shown to 20
DanielYang59 Sep 1, 2024
7de6327
import Self from typing extension
DanielYang59 Sep 1, 2024
35e37b2
remove global ignore of S311 as there're only 2 violation
DanielYang59 Sep 1, 2024
2d70feb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 1, 2024
d9f152a
replace random with numpy, which also fixes S311
DanielYang59 Sep 2, 2024
d6475b8
fix "PT006", # pytest-parametrize-names-wrong-type
DanielYang59 Sep 2, 2024
476560b
guard type check only import
DanielYang59 Sep 2, 2024
5ab3390
fix "COM812", # trailing comma missing
DanielYang59 Sep 2, 2024
8bbbafd
remove no type check mark
DanielYang59 Sep 2, 2024
dc5fc56
Revert "fix "COM812", # trailing comma missing"
DanielYang59 Sep 2, 2024
3e95a83
fix unit test of io
DanielYang59 Sep 2, 2024
acef88d
NEED confirm: change width from 457 to 458
DanielYang59 Sep 2, 2024
10c56c4
clean up branch condition
DanielYang59 Sep 2, 2024
49cbdeb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 2, 2024
6fa85a2
use native array size arg
DanielYang59 Sep 2, 2024
9c8cfa3
revert accidental elem -> element rename
DanielYang59 Sep 2, 2024
4e7904d
fix random array generation
DanielYang59 Sep 2, 2024
e10efa7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 2, 2024
b747012
fix random array generate in asset maker
DanielYang59 Sep 2, 2024
93003af
revert test_io value to 457, reason unknown
DanielYang59 Sep 2, 2024
c12804a
skip eslint for now #197
DanielYang59 Sep 2, 2024
ec270ea
format pre-commit config
DanielYang59 Sep 2, 2024
50ba9c7
remove eslint skip mark in CI
DanielYang59 Sep 2, 2024
4f3826c
fix indentation in pyproject.toml
DanielYang59 Sep 2, 2024
566f6d3
drop quotes in test.yml string
DanielYang59 Sep 2, 2024
28d7f44
fix typo in filename
DanielYang59 Sep 2, 2024
882622e
fix shaded_ys type
DanielYang59 Sep 2, 2024
dfa5194
remove overwriting pytest duration
DanielYang59 Sep 2, 2024
e2f199d
pyproject whitespace
janosh Sep 2, 2024
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
11 changes: 8 additions & 3 deletions pymatviz/phonons.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import sys
from dataclasses import dataclass
from typing import TYPE_CHECKING, Literal, get_args, no_type_check
from typing import TYPE_CHECKING, Literal, get_args

import plotly.express as px
import plotly.graph_objects as go
Expand Down Expand Up @@ -126,7 +126,6 @@ def get_band_xaxis_ticks(
return ticks_x_pos, tick_labels


@no_type_check # TODO: fix this
def _shaded_range(
fig: go.Figure,
shaded_ys: dict[tuple[YMin, YMax], dict[str, Any]] | bool | None,
Expand All @@ -135,9 +134,15 @@ def _shaded_range(
return fig

shade_defaults = dict(layer="below", row="all", col="all")
y_lim = dict(zip(("y_min", "y_max"), fig.layout.yaxis.range, strict=True))
y_lim: dict[float | Literal["y_min", "y_max"], Any] = dict(
zip(("y_min", "y_max"), fig.layout.yaxis.range, strict=True),
)

# DEBUG: why (0, "y_min")
shaded_ys = shaded_ys or {(0, "y_min"): dict(fillcolor="gray", opacity=0.07)}
if not isinstance(shaded_ys, dict):
raise TypeError(f"expect shaded_ys as dict, got {type(shaded_ys).__name__}")

for (y0, y1), kwds in shaded_ys.items():
for y_val in (y0, y1):
if isinstance(y_val, str) and y_val not in y_lim:
Expand Down
Loading