refactor visualstyle.py type annotations
-# Copyright (c) 2019-2021, Manfred Moitzi
+# Copyright (c) 2019-2022, Manfred Moitzi
# License: MIT-License
-from typing import TYPE_CHECKING
+from __future__ import annotations
+from typing import TYPE_CHECKING, Optional
import copy
from ezdxf.lldxf import validator
from ezdxf.lldxf.const import SUBCLASS_MARKER, DXF2000, DXFStructureError
@@ -16,7 +17,8 @@ from .dxfobj import DXFObject
from .factory import register_entity
if TYPE_CHECKING:
- from ezdxf.eztypes import TagWriter, DXFNamespace, DXFEntity
+ from ezdxf.entities import DXFNamespace, DXFEntity
+ from ezdxf.lldxf.tagwriter import AbstractTagWriter
__all__ = ["VisualStyle"]
@@ -148,14 +150,14 @@ class VisualStyle(DXFObject):
super().__init__()
self.acad_xdata = None # to preserve AutoCAD xdata
- def _copy_data(self, entity: "DXFEntity") -> None:
+ def _copy_data(self, entity: DXFEntity) -> None:
"""Copy acad internal data."""
assert isinstance(entity, VisualStyle)
entity.acad_xdata = copy.deepcopy(self.acad_xdata)
def load_dxf_attribs(
- self, processor: SubclassProcessor = None
- ) -> "DXFNamespace":
+ self, processor: Optional[SubclassProcessor] = None
+ ) -> DXFNamespace:
dxf = super().load_dxf_attribs(processor)
if processor:
tags = processor.subclass_by_index(1)
@@ -183,7 +185,7 @@ class VisualStyle(DXFObject):
del tags[index:] # remove xdata from subclass
return xdata
- def export_entity(self, tagwriter: "TagWriter") -> None:
+ def export_entity(self, tagwriter: AbstractTagWriter) -> None:
"""Export entity specific data as DXF tags."""
super().export_entity(tagwriter)
tagwriter.write_tag2(SUBCLASS_MARKER, acdb_visualstyle.name)
