Fix typing errors

This commit is contained in:
Rotzbua 2022-12-31 19:20:55 +01:00 committed by Florian Festi
parent 847159135d
commit 9d6f535e01
5 changed files with 11 additions and 14 deletions

View File

@ -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)

View File

@ -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()

View File

@ -732,9 +732,3 @@ class Gears():
if not teeth_only:
self.boxes.move(width, height, move)
if __name__ == '__main__':
e = Gears()
e.affect()
# Notes

View File

@ -17,7 +17,7 @@
try:
from gettext import gettext as _
except ImportError:
def _(message):
def _(message: str) -> str:
return message
from boxes import *

View File

@ -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: