Skip to content

Commit

Permalink
fix minor code quality issues
Browse files Browse the repository at this point in the history
  • Loading branch information
apparebit committed Oct 11, 2024
1 parent 55fbe24 commit fdf5729
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion prettypretty/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ def write_hires_slice(
) -> None:
frame = FramedBoxes(term, 32, min_width=1)
label = '/'.join(
f'{l.upper()}={level}' if l == hold else l.upper() for l in ('r', 'g', 'b')
f'{axis.upper()}={level}' if axis == hold else axis.upper()
for axis in ('r', 'g', 'b')
)
frame.top(
('Downsampled ' if eight_bit_only else '')
Expand Down
10 changes: 5 additions & 5 deletions prettypretty/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
close_enough,
Color,
ColorSpace,
gamut, # pyright: ignore [reportMissingModuleSource]
spectrum, # pyright: ignore [reportMissingModuleSource]
trans, # pyright: ignore [reportMissingModuleSource]
)
from .color.gamut import GamutTraversalStep # pyright: ignore [reportMissingModuleSource]
from .theme import current_translator


Expand Down Expand Up @@ -267,7 +267,7 @@ def trace_spectrum(
all_colors: list[list[str]] = []

for step in self._illuminated_observer.visual_gamut(spectrum.ONE_NANOMETER):
if isinstance(step, gamut.GamutTraversalStep.MoveTo):
if isinstance(step, GamutTraversalStep.MoveTo):
lines2d.append([])
all_colors.append([])
if locus_only and len(lines2d) > 1:
Expand Down Expand Up @@ -329,7 +329,7 @@ def trace_gamut(self, space: ColorSpace, axes: Any) -> None:
all_points.append(pt)
all_colors.append(hex_format)

if isinstance(step, gamut.GamutTraversalStep.CloseWith):
if isinstance(step, GamutTraversalStep.CloseWith):
break

assert close_enough(all_points[0][0], all_points[-1][0])
Expand Down Expand Up @@ -528,7 +528,7 @@ def create_figure(
light_axes.set_ylim(0, 1)
light_axes.margins(x=0.02, tight=True)

if all(l is not None for l in self._bar_label):
if all(label is not None for label in self._bar_label):
lry_offset = 0.015
light_axes.xaxis.set_major_locator(
FixedLocator([*range(len(self._bar_label))])
Expand Down Expand Up @@ -635,7 +635,7 @@ def main() -> None:

if options.input is not None:
with open(options.input, mode="r", encoding="utf8") as file:
for color in [Color.parse(l) for l in file.readlines() if l.strip()]:
for color in [Color.parse(line) for line in file.readlines() if line.strip()]:
plotter.add(cname, color, marker=marker)

for color in [Color.parse(c) for c in cast(list[str], options.colors) or []]:
Expand Down
2 changes: 1 addition & 1 deletion prettypretty/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ def write_paragraph(self, text: str) -> Self:
being convenient to read. Finally, it writes the resulting text to this
terminal's output. This method does not flush the output.
"""
lines = [l.strip() for l in text.splitlines()]
lines = [line.strip() for line in text.splitlines()]
start = stop = 0

while True:
Expand Down
6 changes: 3 additions & 3 deletions prettypretty/viz3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def generate_faces(self) -> None:

msg = ""
if trace_enabled:
msg = f"capstones "
msg = "capstones "

for edge in [(r, s), (t, s), (r, t), (u, w), (v, w), (u, v)]:
assert edge[0] <= edge[1]
Expand Down Expand Up @@ -656,15 +656,15 @@ def render(*, filename: str, label: str, is_ok: bool) -> None:
sys.exit(1)

if options.planar_gamut and gamut is None:
log(f"The --planar-gamut option requires the --gamut option")
log("The --planar-gamut option requires the --gamut option")
sys.exit(1)

# -------------------------------------------------------------------------- Stride
stride = 2
if options.stride:
try:
stride = int(options.stride)
except:
except ValueError:
log(f"stride {stride} is not an integer")
sys.exit(1)
if not (1 <= stride <= 20):
Expand Down

0 comments on commit fdf5729

Please sign in to comment.