fix typing errors in commands.py
... only 2075 (mypy) typing errors remaining :)
# Copyright (c) 2021, Manfred Moitzi
# License: MIT License
-from typing import Callable, Optional, Dict
+from typing import Callable, Optional, Dict, TYPE_CHECKING, Type
import abc
import sys
import os
@@ -13,6 +13,10 @@ from ezdxf import recover
from ezdxf.lldxf import const
from ezdxf.lldxf.validator import is_dxf_file
+if TYPE_CHECKING:
+ from ezdxf.eztypes import DXFGraphic
+ from ezdxf.addons.drawing.properties import Properties
+
__all__ = ["get", "add_parsers"]
logger = logging.getLogger("ezdxf")
@@ -46,10 +50,10 @@ class Command:
pass
-_commands: Dict[str, Command] = dict()
+_commands: Dict[str, Type[Command]] = dict()
-def register(cls: Command):
+def register(cls: Type[Command]):
"""Register a launcher sub-command."""
_commands[cls.NAME] = cls
return cls
@@ -141,7 +145,7 @@ class Audit(Command):
def run(args):
def build_outname(name: str) -> str:
p = Path(name)
- return p.parent / (p.stem + ".rec.dxf")
+ return str(p.parent / (p.stem + ".rec.dxf"))
def log_fixes(auditor):
for error in auditor.fixes:
@@ -323,8 +327,10 @@ class Draw(Command):
try:
layout = doc.layouts.get(args.layout)
except KeyError:
- print(f'Could not find layout "{args.layout}". '
- f'Valid layouts: {[l.name for l in doc.layouts]}')
+ print(
+ f'Could not find layout "{args.layout}". '
+ f"Valid layouts: {[l.name for l in doc.layouts]}"
+ )
sys.exit(1)
fig = plt.figure()
@@ -337,9 +343,11 @@ class Draw(Command):
layer_properties.is_visible = True
if args.all_entities_visible:
+
class AllVisibleFrontend(Frontend):
- def override_properties(self, entity: "DXFGraphic",
- properties: "Properties") -> None:
+ def override_properties(
+ self, entity: "DXFGraphic", properties: "Properties"
+ ) -> None:
properties.is_visible = True
frontend = AllVisibleFrontend(ctx, out)
