Break longer lines not caught by black

because they were unbroken strings or comments
This commit is contained in:
Daniel Rojas 2021-10-21 12:05:00 +02:00 committed by KV
parent 95cc1be647
commit cc0bd76e99
6 changed files with 54 additions and 25 deletions

View File

@ -14,7 +14,8 @@ from wireviz.wv_colors import (
)
from wireviz.wv_helper import aspect_ratio, awg_equiv, mm2_equiv
# Each type alias have their legal values described in comments - validation might be implemented in the future
# Each type alias have their legal values described in comments
# - validation might be implemented in the future
PlainText = str # Text not containing HTML tags nor newlines
Hypertext = str # Text possibly including HTML hyperlinks that are removed in all outputs except HTML output
MultilineHypertext = (
@ -280,7 +281,8 @@ class Connector(Component):
)
if not self.pincount:
raise Exception(
"You need to specify at least one, pincount, pins, pinlabels, or pincolors"
"You need to specify at least one: "
"pincount, pins, pinlabels, or pincolors"
)
# create default list for pins (sequential) if not specified
@ -317,7 +319,8 @@ class Connector(Component):
self.show_pincount = self.style != "simple"
for loop in self.loops:
# TODO: allow using pin labels in addition to pin numbers, just like when defining regular connections
# TODO: allow using pin labels in addition to pin numbers,
# just like when defining regular connections
# TODO: include properties of wire used to create the loop
if len(loop) != 2:
raise Exception("Loops must be between exactly two pins!")
@ -431,13 +434,15 @@ class Cable(Component):
g, u = self.gauge.split(" ")
except Exception:
raise Exception(
f"Cable {self.name} gauge={self.gauge} - Gauge must be a number, or number and unit separated by a space"
f"Cable {self.name} gauge={self.gauge} - "
"Gauge must be a number, or number and unit separated by a space"
)
self.gauge = g
if self.gauge_unit is not None:
print(
f"Warning: Cable {self.name} gauge_unit={self.gauge_unit} is ignored because its gauge contains {u}"
f"Warning: Cable {self.name} gauge_unit={self.gauge_unit} "
f"is ignored because its gauge contains {u}"
)
if u.upper() == "AWG":
self.gauge_unit = u.upper()
@ -456,12 +461,14 @@ class Cable(Component):
L = float(L)
except Exception:
raise Exception(
f"Cable {self.name} length={self.length} - Length must be a number, or number and unit separated by a space"
f"Cable {self.name} length={self.length} - "
"Length must be a number, or number and unit separated by a space"
)
self.length = L
if self.length_unit is not None:
print(
f"Warning: Cable {self.name} length_unit={self.length_unit} is ignored because its length contains {u}"
f"Warning: Cable {self.name} length_unit={self.length_unit} is ignored "
f"because its length contains {u}"
)
self.length_unit = u
elif not any(isinstance(self.length, t) for t in [int, float]):
@ -488,7 +495,8 @@ class Cable(Component):
else: # wirecount implicit in length of color list
if not self.colors:
raise Exception(
"Unknown number of wires. Must specify wirecount or colors (implicit length)"
"Unknown number of wires. "
"Must specify wirecount or colors (implicit length)"
)
self.wirecount = len(self.colors)
@ -498,7 +506,8 @@ class Cable(Component):
'"s" may not be used as a wire label for a shielded cable.'
)
# if lists of part numbers are provided check this is a bundle and that it matches the wirecount.
# if lists of part numbers are provided,
# check this is a bundle and that it matches the wirecount.
for idfield in [self.manufacturer, self.mpn, self.supplier, self.spn, self.pn]:
if isinstance(idfield, list):
if self.category == "bundle":

View File

@ -88,9 +88,11 @@ class Harness:
if pin in connector.pins and pin in connector.pinlabels:
if connector.pins.index(pin) != connector.pinlabels.index(pin):
raise Exception(
f"{name}:{pin} is defined both in pinlabels and pins, for different pins."
f"{name}:{pin} is defined both in pinlabels and pins, "
"for different pins."
)
# TODO: Maybe issue a warning if present in both lists but referencing the same pin?
# TODO: Maybe issue a warning if present in both lists
# but referencing the same pin?
if pin in connector.pinlabels:
if connector.pinlabels.count(pin) > 1:
raise Exception(f"{name}:{pin} is defined more than once.")
@ -110,9 +112,11 @@ class Harness:
if via_wire in cable.colors and via_wire in cable.wirelabels:
if cable.colors.index(via_wire) != cable.wirelabels.index(via_wire):
raise Exception(
f"{via_name}:{via_wire} is defined both in colors and wirelabels, for different wires."
f"{via_name}:{via_wire} is defined both in colors and wirelabels, "
"for different wires."
)
# TODO: Maybe issue a warning if present in both lists but referencing the same wire?
# TODO: Maybe issue a warning if present in both lists
# but referencing the same wire?
if via_wire in cable.colors:
if cable.colors.count(via_wire) > 1:
raise Exception(

View File

@ -93,7 +93,8 @@ def parse(
output_file = output_dir / output_name
if yaml_file:
# if reading from file, ensure that input file's parent directory is included in image_paths
# if reading from file, ensure that input file's parent directory
# is included in image_paths
default_image_path = yaml_file.parent.resolve()
if not default_image_path in [Path(x).resolve() for x in image_paths]:
image_paths.append(default_image_path)
@ -128,7 +129,8 @@ def parse(
if len(yaml_data[sec]) > 0: # section has contents
if ty == dict:
for key, attribs in yaml_data[sec].items():
# The Image dataclass might need to open an image file with a relative path.
# The Image dataclass might need to open
# an image file with a relative path.
image = attribs.get("image")
if isinstance(image, dict):
image_path = image["src"]
@ -164,12 +166,16 @@ def parse(
autogenerated_designators[template] = (
autogenerated_designators.get(template, 0) + 1
)
designator = f"{AUTOGENERATED_PREFIX}{template}_{autogenerated_designators[template]}"
designator = (
f"{AUTOGENERATED_PREFIX}"
"{template}_{autogenerated_designators[template]}"
)
# check if redefining existing component to different template
if designator in designators_and_templates:
if designators_and_templates[designator] != template:
raise Exception(
f"Trying to redefine {designator} from {designators_and_templates[designator]} to {template}"
f"Trying to redefine {designator}"
f" from {designators_and_templates[designator]} to {template}"
)
else:
designators_and_templates[designator] = template
@ -300,7 +306,8 @@ def parse(
f"{template} is an unknown template/designator/arrow."
)
alternate_type() # entries in connection set must alternate between connectors and cables/arrows
# entries in connection set must alternate between connectors and cables/arrows
alternate_type()
# transpose connection set list
# before: one item per component, one subitem per connection in set

View File

@ -58,7 +58,10 @@ epilog += ", ".join([f"{key} ({value.upper()})" for key, value in format_codes.i
"--output-name",
default=None,
type=str,
help="File name (without extension) to use for output files, if different from input file name.",
help=(
"File name (without extension) to use for output files, "
"if different from input file name."
),
)
@click.option(
"-V",

View File

@ -430,7 +430,8 @@ def image_and_caption_cells(component: Component) -> (Td, Td):
image_tag = Img(scale=component.image.scale, src=component.image.src)
image_cell_inner = Td(image_tag, flat=True)
if component.image.fixedsize:
# further nest the image in a table with width/height/fixedsize parameters, and place that table in a cell
# further nest the image in a table with width/height/fixedsize parameters,
# and place that table in a cell
image_cell_inner.update_attribs(**html_size_attr_dict(component.image))
image_cell = Td(
Table(Tr(image_cell_inner), border=0, cellborder=0, cellspacing=0, id="!")
@ -500,7 +501,8 @@ def apply_dot_tweaks(dot, tweak):
def typecheck(name: str, value: Any, expect: type) -> None:
if not isinstance(value, expect):
raise Exception(
f"Unexpected value type of {name}: Expected {expect}, got {type(value)}\n{value}"
f"Unexpected value type of {name}: "
f"Expected {expect}, got {type(value)}\n{value}"
)
# TODO?: Differ between override attributes and HTML?
@ -530,11 +532,13 @@ def apply_dot_tweaks(dot, tweak):
)
if n_subs < 1:
print(
f"Harness.create_graph() warning: {attr} not found in {keyword}!"
"Harness.create_graph() warning: "
f"{attr} not found in {keyword}!"
)
elif n_subs > 1:
print(
f"Harness.create_graph() warning: {attr} removed {n_subs} times in {keyword}!"
"Harness.create_graph() warning: "
f"{attr} removed {n_subs} times in {keyword}!"
)
continue
@ -549,7 +553,8 @@ def apply_dot_tweaks(dot, tweak):
entry = re.sub(r"\]$", f" {attr}={value}]", entry)
elif n_subs > 1:
print(
f"Harness.create_graph() warning: {attr} overridden {n_subs} times in {keyword}!"
"Harness.create_graph() warning: "
f"{attr} overridden {n_subs} times in {keyword}!"
)
dot.body[i] = entry

View File

@ -25,7 +25,8 @@ def generate_html_output(
# load HTML template
templatename = metadata.get("template", {}).get("name")
if templatename:
# if relative path to template was provided, check directory of YAML file first, fall back to built-in template directory
# if relative path to template was provided,
# check directory of YAML file first, fall back to built-in template directory
templatefile = smart_file_resolve(
f"{templatename}.html",
[Path(filename).parent, Path(__file__).parent / "templates"],