python: add type annotations
This commit is contained in:
10
main.py
10
main.py
@@ -38,7 +38,7 @@ DEFAULT_BATTERY = "ldtek"
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def export_png_image(obj, file_: str, orientation: str):
|
||||
def export_png_image(obj: cq.Workplane, file_: str, orientation: str) -> None:
|
||||
assy = _to_assy(obj)
|
||||
renderer = toVTK(assy)
|
||||
win = vtkRenderWindow()
|
||||
@@ -77,7 +77,7 @@ def export_png_image(obj, file_: str, orientation: str):
|
||||
exporter.Write()
|
||||
|
||||
|
||||
def _model(as_assy: bool=False):
|
||||
def _model(as_assy: bool=False) -> cq.Workplane:
|
||||
logger.info("computing model ...")
|
||||
battery_name = os.environ.get("CASE_BATTERY", DEFAULT_BATTERY)
|
||||
render_phone = os.environ.get("CASE_RENDER_PHONE", "") not in ("", "0")
|
||||
@@ -93,8 +93,8 @@ def _model(as_assy: bool=False):
|
||||
battery = ldtek_battery.LdtekBattery()
|
||||
return case.case(phone, battery=battery, render_phone=render_phone, as_assy=as_assy)
|
||||
|
||||
_computedModels = {}
|
||||
def model(as_assy: bool=False):
|
||||
_computedModels: dict[(bool,), cq.Workplane] = {}
|
||||
def model(as_assy: bool=False) -> cq.Workplane:
|
||||
""" memoized wrapper around `_model` """
|
||||
global _computedModels
|
||||
key = (as_assy, )
|
||||
@@ -102,7 +102,7 @@ def model(as_assy: bool=False):
|
||||
_computedModels[key] = _model(as_assy=as_assy)
|
||||
return _computedModels[key]
|
||||
|
||||
def main():
|
||||
def main() -> None:
|
||||
logging.basicConfig()
|
||||
logging.getLogger().setLevel(logging.INFO)
|
||||
|
||||
|
Reference in New Issue
Block a user