Skip to content

Commit

Permalink
Fix code issues reported by mypy and ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
Argmaster committed Nov 1, 2023
1 parent be57594 commit e5e2a7b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
}
],
"mypy-type-checker.importStrategy": "useBundled",
"black-formatter.importStrategy": "fromEnvironment",
"black-formatter.importStrategy": "useBundled",
"cSpell.ignoreWords": ["RRGGBB", "RRGGBBAA"],
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#3399ff",
Expand All @@ -129,5 +129,6 @@
"titleBar.inactiveBackground": "#007fff99",
"titleBar.inactiveForeground": "#e7e7e799"
},
"peacock.color": "#007fff"
"peacock.color": "#007fff",
"mypy-type-checker.args": ["--config-file=pyproject.toml"]
}
6 changes: 5 additions & 1 deletion src/pygerber/backend/rasterized_2d/backend_cls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import TYPE_CHECKING, ClassVar, Optional

import numpy as np
import numpy.typing as npt
from PIL import Image

from pygerber.backend.abstract.backend_cls import Backend, BackendOptions
Expand Down Expand Up @@ -170,7 +171,10 @@ def _replace_image_colors(self) -> None:
np_img = np.array(img)

# Create an empty RGBA image with the same size as the original image
rgba_img = np.zeros((img.height, img.width, 4), dtype=np.uint8)
rgba_img: npt.NDArray[np.uint8] = np.zeros(
(img.height, img.width, 4),
dtype=np.uint8,
)

# For each grayscale value, set the corresponding RGBA value in the new image
for gray_value, rgba in color_map.items():
Expand Down
6 changes: 3 additions & 3 deletions src/pygerber/backend/rasterized_2d/color_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ def get_grayscale_to_rgba_color_map(self) -> dict[int, tuple[int, int, int, int]
"""Return grayscale to RGBA color map."""
return {
Polarity.Dark.get_2d_rasterized_color(): self.solid_color.as_rgba_int(),
Polarity.Clear.get_2d_rasterized_color(): self.clear_color.as_rgba_int(), # noqa: E501
Polarity.Clear.get_2d_rasterized_color(): self.clear_color.as_rgba_int(),
Polarity.DarkRegion.get_2d_rasterized_color(): self.solid_region_color.as_rgba_int(), # noqa: E501
Polarity.ClearRegion.get_2d_rasterized_color(): self.clear_region_color.as_rgba_int(), # noqa: E501
Polarity.Background.get_2d_rasterized_color(): self.background_color.as_rgba_int(), # noqa: E501
Polarity.DEBUG.get_2d_rasterized_color(): self.debug_1_color.as_rgba_int(), # noqa: E501
Polarity.DEBUG2.get_2d_rasterized_color(): self.debug_2_color.as_rgba_int(), # noqa: E501
Polarity.DEBUG.get_2d_rasterized_color(): self.debug_1_color.as_rgba_int(),
Polarity.DEBUG2.get_2d_rasterized_color(): self.debug_2_color.as_rgba_int(),
}


Expand Down

0 comments on commit e5e2a7b

Please sign in to comment.