.pyi files work slightly better with these changes. Also: regenerating Python stubs.

This commit is contained in:
Matthias Koefferlein 2024-06-30 17:57:36 +02:00
parent 564861abe1
commit 6992ac67b0
7 changed files with 12682 additions and 675 deletions

View File

@ -55,7 +55,7 @@ echo "Generating stubs for tl .."
$python $inst/stubgen.py tl >$pyi_srcdir/tlcore.pyi
echo "Generating stubs for db .."
$python $inst/stubgen.py db tl >$pyi_srcdir/dbcore.pyi
$python $inst/stubgen.py db tl,lay,rdb >$pyi_srcdir/dbcore.pyi
echo "Generating stubs for rdb .."
$python $inst/stubgen.py rdb tl,db >$pyi_srcdir/rdbcore.pyi

View File

@ -192,6 +192,10 @@ class Stub:
stub.format_stub(include_docstring=include_docstring), " " * 4
)
if self.indent_docstring and (include_docstring or len(self.child_stubs)):
stub_str += "\n"
stub_str += indent("...", " " * 4)
return stub_str
@ -369,7 +373,8 @@ def get_py_methods(
# Exceptions:
# For X.__eq__(self, a:X), treat second argument as type object instead of X
if name in ("__eq__", "__ne__"):
arg_list[1] = arg_list[1][0], "object"
if arg_list[1][1].cls() is not None and arg_list[1][1].cls().__gsi_id__ == c.__gsi_id__:
arg_list[1] = arg_list[1][0], "object"
# X._assign(self, other:X), mypy complains if _assign is defined at base class.
# We can't specialize other in this case.
elif name in ("_assign", "assign"):
@ -454,6 +459,7 @@ def get_module_stubs(module: str) -> List[ClassStub]:
def print_mod(module, dependencies):
print("from typing import Any, ClassVar, Dict, Sequence, List, Iterator, Optional")
print("from typing import overload")
print("from __future__ import annotations")
for dep in dependencies:
print(f"import klayout.{dep} as {dep}")
for stub in get_module_stubs(module):

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,5 @@
from typing import Any, ClassVar, Dict, Sequence, List, Iterator, Optional
from typing import overload
from __future__ import annotations
import klayout.tl as tl
import klayout.db as db

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff