Skip to content

Commit

Permalink
update ruff and pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-goeldi committed Jan 12, 2025
1 parent 272f494 commit 888bf2b
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repos:
exclude: 'changelog\.d/.*|CHANGELOG\.md'
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.8.4
rev: v0.9.1
hooks:
# Run the linter.
- id: ruff
Expand Down Expand Up @@ -49,7 +49,7 @@ repos:
# ignore all tests, not just tests data
exclude: ^tests/
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.14.0' # Use the sha / tag you want to point at
rev: 'v1.14.1' # Use the sha / tag you want to point at
hooks:
- id: mypy
require_serial: true
Expand Down
14 changes: 6 additions & 8 deletions src/kfactory/enclosure.py
Original file line number Diff line number Diff line change
Expand Up @@ -906,9 +906,7 @@ def apply_minkowski_tiled(
"main_layer.minkowski_sum(max_shape).merged();"
)
case d if d < 0:
max_region = (
"var max_reg = tile_reg - " "(tile_reg - main_layer);"
)
max_region = "var max_reg = tile_reg - (tile_reg - main_layer);"
case 0:
max_region = "var max_reg = main_layer & tile_reg;"
queue_str += max_region
Expand Down Expand Up @@ -1169,9 +1167,9 @@ def enclosures_must_have_main_layer(
The PDK Enclosure uses this to automatically apply enclosures.
"""
for le in v:
assert (
le.main_layer is not None
), "Enclosure for PDKEnclosure must have a main layer defined"
assert le.main_layer is not None, (
"Enclosure for PDKEnclosure must have a main layer defined"
)
return v

def __getitem__(self, key: str | int) -> LayerEnclosure:
Expand Down Expand Up @@ -1619,7 +1617,7 @@ def apply_minkowski_tiled(
)
case d if d < 0:
max_region = (
"var max_reg = tile_reg - " f"(tile_reg - {_inp});"
f"var max_reg = tile_reg - (tile_reg - {_inp});"
)
case 0:
max_region = f"var max_reg = {_inp} & tile_reg;"
Expand All @@ -1645,7 +1643,7 @@ def apply_minkowski_tiled(
min_region = f"var min_reg = {_inp} & tile_reg;"
queue_str += min_region
queue_str += (
f"_output({_out}," "(max_reg - min_reg) & _tile, true);"
f"_output({_out},(max_reg - min_reg) & _tile, true);"
)
else:
queue_str += f"_output({_out}, max_reg & _tile, true);"
Expand Down
12 changes: 6 additions & 6 deletions src/kfactory/kcell.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,11 +762,11 @@ def port_check(p1: Port, p2: Port, checks: PortCheck = PortCheck.all_opposite) -
assert (
p1.trans == p2.trans * kdb.Trans.R180
or p1.trans == p2.trans * kdb.Trans.M90
), "Transformations of ports not matching for opposite check" f"{p1=} {p2=}"
), f"Transformations of ports not matching for opposite check{p1=} {p2=}"
if (checks & PortCheck.opposite) == 0:
assert (
p1.trans == p2.trans or p1.trans == p2.trans * kdb.Trans.M0
), f"Transformations of ports not matching for overlapping check {p1=} {p2=}"
assert p1.trans == p2.trans or p1.trans == p2.trans * kdb.Trans.M0, (
f"Transformations of ports not matching for overlapping check {p1=} {p2=}"
)
if checks & PortCheck.width:
assert p1.width == p2.width, f"Width mismatch for {p1=} {p2=}"
if checks & PortCheck.layer:
Expand Down Expand Up @@ -4204,7 +4204,7 @@ def find_layer(
if allow_undefined_layers:
return self.layout.layer(info)
raise KeyError(
f"Layer '{args=}, {kwargs=}' has not been defined in the " "KCLayout."
f"Layer '{args=}, {kwargs=}' has not been defined in the KCLayout."
)

@overload
Expand Down Expand Up @@ -8302,7 +8302,7 @@ def get_cell_name(

if len(name) > max_cellname_length:
name_hash = sha3_512(name.encode()).hexdigest()[:8]
name = f"{name[:(max_cellname_length - 9)]}_{name_hash}"
name = f"{name[: (max_cellname_length - 9)]}_{name_hash}"

return name

Expand Down
2 changes: 1 addition & 1 deletion src/kfactory/routing/manhattan.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ def route_smart(
length = len(start_ports)
if len(kwargs) > 0:
raise ValueError(
"Additional args and kwargs are not allowed for route_smart." f"{kwargs=}"
f"Additional args and kwargs are not allowed for route_smart.{kwargs=}"
)

if bend90_radius is None or separation is None:
Expand Down
2 changes: 1 addition & 1 deletion src/kfactory/routing/optical.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def place90(
"""
if len(kwargs) > 0:
raise ValueError(
"Additional args and kwargs are not allowed for route_smart." f"{kwargs=}"
f"Additional args and kwargs are not allowed for route_smart.{kwargs=}"
)
if allow_width_mismatch is None:
allow_width_mismatch = config.allow_width_mismatch
Expand Down
38 changes: 19 additions & 19 deletions src/kfactory/technology/layer_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ def group2lp(lp: LayerGroupModel) -> lay.LayerPropertiesNode:
dither_patterns = {
"solid": "*",
"hollow": ".",
"dotted": "*.\n" ".*",
"coarsely dotted": "*...\n" "....\n" "..*.\n" "....",
"left-hatched": "*...\n" ".*..\n" "..*.\n" "...*",
"dotted": "*.\n.*",
"coarsely dotted": "*...\n....\n..*.\n....",
"left-hatched": "*...\n.*..\n..*.\n...*",
"lightly left-hatched": "*.......\n"
".*......\n"
"..*.....\n"
Expand All @@ -228,7 +228,7 @@ def group2lp(lp: LayerGroupModel) -> lay.LayerPropertiesNode:
".....*..\n"
"......*.\n"
".......*",
"strongly left-hatched dense": "**..\n" ".**.\n" "..**\n" "*..*",
"strongly left-hatched dense": "**..\n.**.\n..**\n*..*",
"strongly left-hatched sparse": "**......\n"
".**.....\n"
"..**....\n"
Expand All @@ -237,7 +237,7 @@ def group2lp(lp: LayerGroupModel) -> lay.LayerPropertiesNode:
".....**.\n"
"......**\n"
"*......*",
"right-hatched": "*...\n" "...*\n" "..*.\n" ".*..",
"right-hatched": "*...\n...*\n..*.\n.*..",
"lightly right-hatched": "*.......\n"
".......*\n"
"......*.\n"
Expand All @@ -246,7 +246,7 @@ def group2lp(lp: LayerGroupModel) -> lay.LayerPropertiesNode:
"...*....\n"
"..*.....\n"
".*......",
"strongly right-hatched dense": "**..\n" "*..*\n" "..**\n" ".**.",
"strongly right-hatched dense": "**..\n*..*\n..**\n.**.",
"strongly right-hatched sparse": "**......\n"
"*......*\n"
"......**\n"
Expand All @@ -255,7 +255,7 @@ def group2lp(lp: LayerGroupModel) -> lay.LayerPropertiesNode:
"...**...\n"
"..**....\n"
".**.....",
"cross-hatched": "*...\n" ".*.*\n" "..*.\n" ".*.*",
"cross-hatched": "*...\n.*.*\n..*.\n.*.*",
"lightly cross-hatched": "*.......\n"
".*.....*\n"
"..*...*.\n"
Expand All @@ -264,7 +264,7 @@ def group2lp(lp: LayerGroupModel) -> lay.LayerPropertiesNode:
"...*.*..\n"
"..*...*.\n"
".*.....*",
"checkerboard 2px": "**..\n" "**..\n" "..**\n" "..**",
"checkerboard 2px": "**..\n**..\n..**\n..**",
"strongly cross-hatched sparse": "**......\n"
"***....*\n"
"..**..**\n"
Expand Down Expand Up @@ -401,14 +401,14 @@ def group2lp(lp: LayerGroupModel) -> lay.LayerPropertiesNode:
"..*...*.\n"
"*....*..\n"
".*.*....",
"vertical dense": "*.\n" "*.\n",
"vertical": ".*..\n" ".*..\n" ".*..\n" ".*..\n",
"vertical thick": ".**.\n" ".**.\n" ".**.\n" ".**.\n",
"vertical sparse": "...*....\n" "...*....\n" "...*....\n" "...*....\n",
"vertical sparse, thick": "...**...\n" "...**...\n" "...**...\n" "...**...\n",
"horizontal dense": "**\n" "..\n",
"horizontal": "....\n" "****\n" "....\n" "....\n",
"horizontal thick": "....\n" "****\n" "****\n" "....\n",
"vertical dense": "*.\n*.\n",
"vertical": ".*..\n.*..\n.*..\n.*..\n",
"vertical thick": ".**.\n.**.\n.**.\n.**.\n",
"vertical sparse": "...*....\n...*....\n...*....\n...*....\n",
"vertical sparse, thick": "...**...\n...**...\n...**...\n...**...\n",
"horizontal dense": "**\n..\n",
"horizontal": "....\n****\n....\n....\n",
"horizontal thick": "....\n****\n****\n....\n",
"horizontal sparse": "........\n"
"........\n"
"........\n"
Expand All @@ -425,9 +425,9 @@ def group2lp(lp: LayerGroupModel) -> lay.LayerPropertiesNode:
"........\n"
"........\n"
"........\n",
"grid dense": "**\n" "*.\n",
"grid": ".*..\n" "****\n" ".*..\n" ".*..\n",
"grid thick": ".**.\n" "****\n" "****\n" ".**.\n",
"grid dense": "**\n*.\n",
"grid": ".*..\n****\n.*..\n.*..\n",
"grid thick": ".**.\n****\n****\n.**.\n",
"grid sparse": "...*....\n"
"...*....\n"
"...*....\n"
Expand Down

0 comments on commit 888bf2b

Please sign in to comment.