From 9d6f535e0174aea138c58d29e423ded690fd9616 Mon Sep 17 00:00:00 2001 From: Rotzbua Date: Sat, 31 Dec 2022 19:20:55 +0100 Subject: [PATCH] Fix typing errors --- boxes/__init__.py | 5 +++-- boxes/edges.py | 9 +++++---- boxes/gears.py | 6 ------ boxes/generators/ottobody.py | 2 +- scripts/boxesserver | 3 ++- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/boxes/__init__.py b/boxes/__init__.py index 2c169a8..8c43302 100755 --- a/boxes/__init__.py +++ b/boxes/__init__.py @@ -24,6 +24,7 @@ from argparse import ArgumentParser from contextlib import contextmanager from functools import wraps from shlex import quote +from typing import Optional, List from xml.sax.saxutils import quoteattr from shapely.geometry import * @@ -181,9 +182,9 @@ class ArgparseEdgeType: """argparse type to select from a set of edge types""" names = edges.getDescriptions() - edges = [] + edges: List[str] = [] - def __init__(self, edges=None): + def __init__(self, edges: Optional[str] = None): if edges: self.edges = list(edges) diff --git a/boxes/edges.py b/boxes/edges.py index f5a088d..16b6a8c 100644 --- a/boxes/edges.py +++ b/boxes/edges.py @@ -19,6 +19,7 @@ import argparse import inspect import math import re +from typing import Optional, Dict, Any from boxes import gears @@ -167,8 +168,8 @@ class Settings(object): the suported keys and default values. The values are available via attribute access. """ - absolute_params = {} - relative_params = {} + absolute_params: Dict[str, Any] = {} # TODO find better typing. + relative_params: Dict[str, Any] = {} # TODO find better typing. @classmethod def parserArguments(cls, parser, prefix=None, **defaults): @@ -299,7 +300,7 @@ class Settings(object): class BaseEdge(object): """Abstract base class for all Edges""" - char = None + char: Optional[str] = None description = "Abstract Edge Class" def __init__(self, boxes, settings): @@ -1907,7 +1908,7 @@ Values: """ - __doc__ += FingerJointSettings.__doc__ + __doc__ += FingerJointSettings.__doc__ or "" absolute_params = FingerJointSettings.absolute_params.copy() relative_params = FingerJointSettings.relative_params.copy() diff --git a/boxes/gears.py b/boxes/gears.py index 0a857cd..72d9ade 100644 --- a/boxes/gears.py +++ b/boxes/gears.py @@ -732,9 +732,3 @@ class Gears(): if not teeth_only: self.boxes.move(width, height, move) -if __name__ == '__main__': - e = Gears() - e.affect() - -# Notes - diff --git a/boxes/generators/ottobody.py b/boxes/generators/ottobody.py index a6ff548..c00988a 100644 --- a/boxes/generators/ottobody.py +++ b/boxes/generators/ottobody.py @@ -17,7 +17,7 @@ try: from gettext import gettext as _ except ImportError: - def _(message): + def _(message: str) -> str: return message from boxes import * diff --git a/scripts/boxesserver b/scripts/boxesserver index 6e4560d..e621309 100755 --- a/scripts/boxesserver +++ b/scripts/boxesserver @@ -82,7 +82,8 @@ class ArgumentParserError(Exception): pass class ThrowingArgumentParser(argparse.ArgumentParser): def error(self, message): raise ArgumentParserError(message) -boxes.ArgumentParser = ThrowingArgumentParser # Evil hack +# Evil hack +boxes.ArgumentParser = ThrowingArgumentParser # type: ignore class BServer: