From 0f49924aa694503de9ac2361fcd1b77a0f9f9da5 Mon Sep 17 00:00:00 2001 From: jan Date: Mon, 16 Feb 2026 18:04:16 -0800 Subject: [PATCH] Add ezdxf stubs --- stubs/ezdxf/__init__.pyi | 12 ++++++++++++ stubs/ezdxf/entities.pyi | 17 +++++++++++++++++ stubs/ezdxf/enums.pyi | 4 ++++ stubs/ezdxf/layouts.pyi | 20 ++++++++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 stubs/ezdxf/__init__.pyi create mode 100644 stubs/ezdxf/entities.pyi create mode 100644 stubs/ezdxf/enums.pyi create mode 100644 stubs/ezdxf/layouts.pyi diff --git a/stubs/ezdxf/__init__.pyi b/stubs/ezdxf/__init__.pyi new file mode 100644 index 0000000..0198407 --- /dev/null +++ b/stubs/ezdxf/__init__.pyi @@ -0,0 +1,12 @@ +from typing import Any, TextIO, Iterable +from .layouts import Modelspace, BlockRecords + +class Drawing: + blocks: BlockRecords + @property + def layers(self) -> Iterable[Any]: ... + def modelspace(self) -> Modelspace: ... + def write(self, stream: TextIO) -> None: ... + +def new(version: str = ..., setup: bool = ...) -> Drawing: ... +def read(stream: TextIO) -> Drawing: ... diff --git a/stubs/ezdxf/entities.pyi b/stubs/ezdxf/entities.pyi new file mode 100644 index 0000000..c8e6a4b --- /dev/null +++ b/stubs/ezdxf/entities.pyi @@ -0,0 +1,17 @@ +from typing import Any, Iterable, Tuple, Sequence + +class DXFEntity: + def dxfattribs(self) -> dict[str, Any]: ... + def dxftype(self) -> str: ... + +class LWPolyline(DXFEntity): + def get_points(self) -> Iterable[Tuple[float, ...]]: ... + +class Polyline(DXFEntity): + def points(self) -> Iterable[Any]: ... # has .xyz + +class Text(DXFEntity): + def get_placement(self) -> Tuple[int, Tuple[float, float, float]]: ... + def set_placement(self, p: Sequence[float], align: int = ...) -> Text: ... + +class Insert(DXFEntity): ... diff --git a/stubs/ezdxf/enums.pyi b/stubs/ezdxf/enums.pyi new file mode 100644 index 0000000..0dcf600 --- /dev/null +++ b/stubs/ezdxf/enums.pyi @@ -0,0 +1,4 @@ +from enum import IntEnum + +class TextEntityAlignment(IntEnum): + BOTTOM_LEFT = ... diff --git a/stubs/ezdxf/layouts.pyi b/stubs/ezdxf/layouts.pyi new file mode 100644 index 0000000..4e713e6 --- /dev/null +++ b/stubs/ezdxf/layouts.pyi @@ -0,0 +1,20 @@ +from typing import Any, Iterator, Sequence, Union, Iterable +from .entities import DXFEntity + +class BaseLayout: + def __iter__(self) -> Iterator[DXFEntity]: ... + def add_lwpolyline(self, points: Iterable[Sequence[float]], dxfattribs: dict[str, Any] = ...) -> Any: ... + def add_text(self, text: str, dxfattribs: dict[str, Any] = ...) -> Any: ... + def add_blockref(self, name: str, insert: Any, dxfattribs: dict[str, Any] = ...) -> Any: ... + +class Modelspace(BaseLayout): + @property + def name(self) -> str: ... + +class BlockLayout(BaseLayout): + @property + def name(self) -> str: ... + +class BlockRecords: + def new(self, name: str) -> BlockLayout: ... + def __iter__(self) -> Iterator[BlockLayout]: ...