Skip to content

Commit

Permalink
style: format code with Black and isort
Browse files Browse the repository at this point in the history
This commit fixes the style issues introduced in 27ec437 according to the output
from Black and isort.

Details: #21
  • Loading branch information
deepsource-autofix[bot] authored Oct 23, 2023
1 parent 27ec437 commit d81acbc
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 17 deletions.
58 changes: 43 additions & 15 deletions pymint/mintcompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from typing import Dict, Optional

from parchmint import Layer, Target
from parchmint.device import ValveType

from pymint.antlrgen.mintListener import mintListener
from pymint.antlrgen.mintParser import mintParser
from pymint.mintdevice import MINTDevice
from pymint.mintlayer import MINTLayerType
from parchmint.device import ValveType


class MINTCompiler(mintListener):
Expand All @@ -34,7 +34,9 @@ def exitNetlist(self, ctx: mintParser.NetlistContext):

def enterHeader(self, ctx: mintParser.HeaderContext):
if self.current_device is None:
raise Exception("Error Initializing the device. Could not find the current device")
raise Exception(
"Error Initializing the device. Could not find the current device"
)

if ctx.device_name is None:
raise Exception("Could not find Device Name")
Expand All @@ -46,7 +48,9 @@ def exitLayerBlock(self, ctx: mintParser.LayerBlockContext):

def enterFlowBlock(self, ctx: mintParser.FlowBlockContext):
if self.current_device is None:
raise Exception("Error Initializing the device. Could not find the current device")
raise Exception(
"Error Initializing the device. Could not find the current device"
)
layer = self.current_device.create_mint_layer(
str(self.current_layer_id),
str(self.flow_layer_count),
Expand All @@ -59,7 +63,9 @@ def enterFlowBlock(self, ctx: mintParser.FlowBlockContext):

def enterControlBlock(self, ctx: mintParser.ControlBlockContext):
if self.current_device is None:
raise Exception("Error Initializing the device. Could not find the current device")
raise Exception(
"Error Initializing the device. Could not find the current device"
)

layer = self.current_device.create_mint_layer(
str(self.current_layer_id),
Expand All @@ -73,7 +79,9 @@ def enterControlBlock(self, ctx: mintParser.ControlBlockContext):

def enterIntegrationBlock(self, ctx: mintParser.IntegrationBlockContext):
if self.current_device is None:
raise Exception("Error Initializing the device. Could not find the current device")
raise Exception(
"Error Initializing the device. Could not find the current device"
)

layer = self.current_device.create_mint_layer(
str(self.current_layer_id),
Expand Down Expand Up @@ -134,7 +142,9 @@ def enterControlStat(self, ctx: mintParser.ControlStatContext):

def exitPrimitiveStat(self, ctx: mintParser.PrimitiveStatContext):
if self.current_device is None:
raise Exception("Error Initializing the device. Could not find the current device")
raise Exception(
"Error Initializing the device. Could not find the current device"
)

entity = self.current_entity
if entity is None:
Expand All @@ -144,7 +154,9 @@ def exitPrimitiveStat(self, ctx: mintParser.PrimitiveStatContext):
for ufname in ctx.ufnames().ufname(): # type: ignore
if self._current_layer is None:
raise Exception("Current layer is set to None")
if not (self._current_layer is not None and self._current_layer.ID is not None):
if not (
self._current_layer is not None and self._current_layer.ID is not None
):
raise AssertionError
self.current_device.create_mint_component(
ufname.getText(),
Expand Down Expand Up @@ -189,15 +201,19 @@ def exitBankGenStat(self, ctx: mintParser.BankGenStatContext):
component_name = name + "_" + str(i)
if self._current_layer is None:
raise Exception("Current Layer not Set")
if not (self._current_layer is not None and self._current_layer.ID is not None):
if not (
self._current_layer is not None and self._current_layer.ID is not None
):
raise AssertionError
self.current_device.create_mint_component(
component_name, entity, self.current_params, [self._current_layer.ID]
)

def exitGridDeclStat(self, ctx: mintParser.GridDeclStatContext):
if self.current_device is None:
raise Exception("Error Initializing the device. Could not find the current device")
raise Exception(
"Error Initializing the device. Could not find the current device"
)

entity = self.current_entity
if entity is None:
Expand All @@ -218,7 +234,9 @@ def exitGridDeclStat(self, ctx: mintParser.GridDeclStatContext):

def exitChannelStat(self, ctx: mintParser.ChannelStatContext):
if self.current_device is None:
raise Exception("Error Initializing the device. Could not find the current device")
raise Exception(
"Error Initializing the device. Could not find the current device"
)

entity = self.current_entity
if entity is None:
Expand Down Expand Up @@ -309,7 +327,9 @@ def exitNetStat(self, ctx: mintParser.NetStatContext):

def exitSpanStat(self, ctx: mintParser.SpanStatContext):
if self.current_device is None:
raise Exception("Error Initializing the device. Could not find the current device")
raise Exception(
"Error Initializing the device. Could not find the current device"
)

entity = self.current_entity
if entity is None:
Expand Down Expand Up @@ -337,7 +357,9 @@ def exitSpanStat(self, ctx: mintParser.SpanStatContext):
def exitNodeStat(self, ctx: mintParser.NodeStatContext):
entity = "NODE"
if self.current_device is None:
raise Exception("Error Initializing the device. Could not find the current device")
raise Exception(
"Error Initializing the device. Could not find the current device"
)

# Loop for each of the components that need to be created with this param
if not (self._current_layer is not None and self._current_layer.ID is not None):
Expand All @@ -352,7 +374,9 @@ def exitNodeStat(self, ctx: mintParser.NodeStatContext):

def exitValveStat(self, ctx: mintParser.ValveStatContext):
if self.current_device is None:
raise Exception("Error Initializing the device. Could not find the current device")
raise Exception(
"Error Initializing the device. Could not find the current device"
)

entity = self.current_entity
if entity is None:
Expand Down Expand Up @@ -383,14 +407,18 @@ def exitValveStat(self, ctx: mintParser.ValveStatContext):

def enterViaStat(self, ctx: mintParser.ViaStatContext):
if self.current_device is None:
raise Exception("Error Initializing the device. Could not find the current device")
raise Exception(
"Error Initializing the device. Could not find the current device"
)

for ufname in ctx.ufnames().ufname():
self.current_device.add_via(ufname.getText(), [])

def enterTerminalStat(self, ctx: mintParser.TerminalStatContext):
if self.current_device is None:
raise Exception("Error Initializing the device. Could not find the current device")
raise Exception(
"Error Initializing the device. Could not find the current device"
)

terminal_name = ctx.ufname().getText()
pin_number = int(ctx.INT.getText())
Expand Down
8 changes: 6 additions & 2 deletions pymint/mintwriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ def to_component_MINT(component: Component) -> str:
Returns:
str: MINT string fragment
"""
return "{} {} {};".format(component.entity, component.ID, to_params_MINT(component.params))
return "{} {} {};".format(
component.entity, component.ID, to_params_MINT(component.params)
)


def to_valve_MINT(component: Component, connection: Connection) -> str:
Expand All @@ -48,7 +50,9 @@ def to_valve_MINT(component: Component, connection: Connection) -> str:
Returns:
str: MINT string fragment
"""
return "{} {} on {} {};".format(component.entity, component.ID, connection.ID, to_params_MINT(component.params))
return "{} {} on {} {};".format(
component.entity, component.ID, connection.ID, to_params_MINT(component.params)
)


def to_connection_MINT(connection: Connection) -> str:
Expand Down

0 comments on commit d81acbc

Please sign in to comment.