Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Rename NotNone function to not_none
Browse files Browse the repository at this point in the history
  • Loading branch information
mawildoer committed Sep 23, 2024
1 parent 5a62bdd commit 5f77558
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/faebryk/core/graphinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from faebryk.core.graph_backends.default import GraphImpl
from faebryk.core.link import Link, LinkDirect, LinkNamedParent
from faebryk.libs.util import (
NotNone,
not_none,
exceptions_to_log,
try_avoid_endless_recursion,
)
Expand Down Expand Up @@ -75,7 +75,7 @@ def __init__(self) -> None:

@property
def node(self):
return NotNone(self._node)
return not_none(self._node)

@node.setter
def node(self, value: "Node"):
Expand Down
4 changes: 2 additions & 2 deletions src/faebryk/core/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from faebryk.libs.exceptions import FaebrykException
from faebryk.libs.util import (
KeyErrorNotFound,
NotNone,
not_none,
PostInitCaller,
Tree,
cast_assert,
Expand Down Expand Up @@ -478,7 +478,7 @@ def pretty_params(self) -> str:
from faebryk.core.parameter import Parameter

params = {
NotNone(p.get_parent())[1]: p.get_most_narrow()
not_none(p.get_parent())[1]: p.get_most_narrow()
for p in self.get_children(direct_only=True, types=Parameter)
}
params_str = "\n".join(f"{k}: {v}" for k, v in params.items())
Expand Down
4 changes: 2 additions & 2 deletions src/faebryk/exporters/pcb/kicad/pcb.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from faebryk.libs.sexp.dataclass_sexp import get_parent
from faebryk.libs.util import (
KeyErrorNotFound,
NotNone,
not_none,
dataclass_as_kwargs,
find,
find_or,
Expand Down Expand Up @@ -121,7 +121,7 @@ def apply_netlist(pcb_path: Path, netlist_path: Path):
if (
pcb_net_name := find_or(
nets_removed,
lambda x: _nets_same(pcb_nets[NotNone(x)], nl_nets[nl_net_name]),
lambda x: _nets_same(pcb_nets[not_none(x)], nl_nets[nl_net_name]),
default=None,
)
)
Expand Down
4 changes: 2 additions & 2 deletions src/faebryk/exporters/pcb/layout/heuristic_decoupling.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from faebryk.exporters.pcb.kicad.transformer import PCB_Transformer
from faebryk.exporters.pcb.layout.layout import Layout
from faebryk.libs.kicad.fileformats import C_kicad_pcb_file, C_wh
from faebryk.libs.util import KeyErrorNotFound, NotNone, find
from faebryk.libs.util import KeyErrorNotFound, not_none, find

logger = logging.getLogger(__name__)

Check failure on line 18 in src/faebryk/exporters/pcb/layout/heuristic_decoupling.py

View workflow job for this annotation

GitHub Actions / test

Ruff (I001)

src/faebryk/exporters/pcb/layout/heuristic_decoupling.py:4:1: I001 Import block is un-sorted or un-formatted

Expand Down Expand Up @@ -274,7 +274,7 @@ def apply(self, *node: Node):

for n in node:
assert isinstance(n, F.Capacitor)
power = NotNone(n.get_parent_of_type(F.ElectricPower))
power = not_none(n.get_parent_of_type(F.ElectricPower))

place_next_to(power.hv, n, route=True, params=self._params)

Expand Down
4 changes: 2 additions & 2 deletions src/faebryk/exporters/pcb/layout/heuristic_pulls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from faebryk.core.node import Node
from faebryk.exporters.pcb.layout.heuristic_decoupling import Params, place_next_to
from faebryk.exporters.pcb.layout.layout import Layout
from faebryk.libs.util import NotNone
from faebryk.libs.util import not_none

logger = logging.getLogger(__name__)

Expand All @@ -30,7 +30,7 @@ def apply(self, *node: Node):

for n in node:
assert isinstance(n, F.Resistor)
logic = NotNone(n.get_parent_of_type(F.ElectricLogic))
logic = not_none(n.get_parent_of_type(F.ElectricLogic))

place_next_to(logic.signal, n, route=True, params=self._params)

Expand Down
4 changes: 2 additions & 2 deletions src/faebryk/exporters/pcb/layout/typehierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from faebryk.core.moduleinterface import ModuleInterface
from faebryk.core.node import Node
from faebryk.exporters.pcb.layout.layout import Layout
from faebryk.libs.util import NotNone, find_or, groupby
from faebryk.libs.util import not_none, find_or, groupby

logger = logging.getLogger(__name__)

Check failure on line 13 in src/faebryk/exporters/pcb/layout/typehierarchy.py

View workflow job for this annotation

GitHub Actions / test

Ruff (I001)

src/faebryk/exporters/pcb/layout/typehierarchy.py:4:1: I001 Import block is un-sorted or un-formatted

Expand All @@ -35,7 +35,7 @@ def apply(self, *node: Node):
{
n: find_or(
self.layouts,
lambda layout: isinstance(n, NotNone(layout).mod_type),
lambda layout: isinstance(n, not_none(layout).mod_type),
default=None,
)
for n in node
Expand Down
4 changes: 2 additions & 2 deletions src/faebryk/exporters/project/faebryk/project_faebryk.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import black

from faebryk.libs.pycodegen import sanitize_name
from faebryk.libs.util import NotNone
from faebryk.libs.util import not_none

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -125,7 +125,7 @@ def from_t1_netlist(t1_netlist):
def comp_to_faebryk(component):
def get_comp_name(component):
if component["name"].startswith("COMP["):
class_name = NotNone(
class_name = not_none(
re.search(r"\[(.*):.*\]", component["name"])
).group(1)
else:
Expand Down
4 changes: 2 additions & 2 deletions src/faebryk/library/CH344.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from faebryk.core.module import Module
from faebryk.libs.library import L # noqa: F401
from faebryk.libs.units import P
from faebryk.libs.util import NotNone # noqa: F401
from faebryk.libs.util import not_none # noqa: F401

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -38,7 +38,7 @@ class CH344(Module):
@L.rt_field
def single_electric_reference(self):
return F.has_single_electric_reference_defined(
NotNone(F.ElectricLogic.connect_all_module_references(self))
not_none(F.ElectricLogic.connect_all_module_references(self))
)

datasheet = L.f_field(F.has_datasheet_defined)(
Expand Down
4 changes: 2 additions & 2 deletions src/faebryk/library/Pad.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import faebryk.library._F as F
from faebryk.core.moduleinterface import ModuleInterface
from faebryk.libs.util import NotNone
from faebryk.libs.util import not_none


class Pad(ModuleInterface):
Expand Down Expand Up @@ -43,4 +43,4 @@ def find_pad_for_intf_with_parent_that_has_footprint(
return pads

def get_fp(self) -> F.Footprint:
return NotNone(self.get_parent_of_type(F.Footprint))
return not_none(self.get_parent_of_type(F.Footprint))
4 changes: 2 additions & 2 deletions src/faebryk/library/Pinmux.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from faebryk.libs.util import ( # noqa: F401
KeyErrorAmbiguous,
KeyErrorNotFound,
NotNone,
not_none,
find,
)

Expand Down Expand Up @@ -53,7 +53,7 @@ def set_function(self, pin: int | F.Electrical, function: int | F.Electrical):
if isinstance(pin, int):
pin = self._ios[pin]
if isinstance(function, int):
function = NotNone(self._function_matrix[pin][function])
function = not_none(self._function_matrix[pin][function])

if pin in self.configured:
if self.configured[pin].is_connected_to(function):
Expand Down
4 changes: 2 additions & 2 deletions src/faebryk/libs/picker/picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from faebryk.core.module import Module
from faebryk.core.moduleinterface import ModuleInterface
from faebryk.core.parameter import Parameter
from faebryk.libs.util import NotNone, flatten
from faebryk.libs.util import not_none, flatten

logger = logging.getLogger(__name__)

Check failure on line 21 in src/faebryk/libs/picker/picker.py

View workflow job for this annotation

GitHub Actions / test

Ruff (I001)

src/faebryk/libs/picker/picker.py:4:1: I001 Import block is un-sorted or un-formatted

Expand Down Expand Up @@ -142,7 +142,7 @@ def pick_module_by_params(module: Module, options: Iterable[PickerOption]):
return

params = {
NotNone(p.get_parent())[1]: p.get_most_narrow()
not_none(p.get_parent())[1]: p.get_most_narrow()
for p in module.get_children(direct_only=True, types=Parameter)
}

Expand Down
2 changes: 1 addition & 1 deletion src/faebryk/libs/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def repr(self):
return __wrapper[T, P]


def NotNone(x):
def not_none(x):
assert x is not None
return x

Expand Down
4 changes: 2 additions & 2 deletions test/libs/kicad/test_fileformats.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
SEXP_File,
dataclass_dfs,
)
from faebryk.libs.util import ConfigFlag, NotNone, find
from faebryk.libs.util import ConfigFlag, not_none, find

logger = logging.getLogger(__name__)

Check failure on line 26 in test/libs/kicad/test_fileformats.py

View workflow job for this annotation

GitHub Actions / test

Ruff (I001)

test/libs/kicad/test_fileformats.py:4:1: I001 Import block is un-sorted or un-formatted

Expand Down Expand Up @@ -160,7 +160,7 @@ def _effects(pcb: C_kicad_pcb_file):
pcb_reload = C_kicad_pcb_file.loads(pcb.dumps())

assert (
NotNone(_b1_p1(pcb_reload).drill).shape
not_none(_b1_p1(pcb_reload).drill).shape
== C_footprint.C_pad.C_drill.E_shape.stadium
)

Expand Down

0 comments on commit 5f77558

Please sign in to comment.