forked from jan/fatamorgana
improve type annotations in tests
This commit is contained in:
parent
f87dc7d771
commit
5011750637
@ -2,7 +2,8 @@
|
||||
Build files equivalent to the test cases used by KLayout.
|
||||
"""
|
||||
|
||||
from typing import Callable, IO
|
||||
from typing import IO
|
||||
from collections.abc import Callable
|
||||
|
||||
|
||||
from . import (
|
||||
|
@ -1,4 +1,4 @@
|
||||
# type: ignore
|
||||
# mypy: disable-error-code="union-attr"
|
||||
from typing import IO
|
||||
from io import BytesIO
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# type: ignore
|
||||
# mypy: disable-error-code="union-attr"
|
||||
from typing import IO
|
||||
from io import BytesIO
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# type: ignore
|
||||
# mypy: disable-error-code="union-attr"
|
||||
from typing import IO
|
||||
from io import BytesIO
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# type: ignore
|
||||
# mypy: disable-error-code="union-attr"
|
||||
from typing import IO
|
||||
from io import BytesIO
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
# type: ignore
|
||||
from typing import IO
|
||||
from io import BytesIO
|
||||
import struct
|
||||
|
@ -1,5 +1,5 @@
|
||||
# type: ignore
|
||||
from typing import Sequence, IO
|
||||
from typing import IO
|
||||
from collections.abc import Sequence
|
||||
|
||||
from io import BytesIO
|
||||
|
||||
@ -27,7 +27,7 @@ def base_tests(layout: OasisLayout) -> None:
|
||||
assert not layout.cellnames
|
||||
|
||||
assert len(layout.cells) == 1
|
||||
assert layout.cells[0].name.string == 'A'
|
||||
assert layout.cells[0].name.string == 'A' # type: ignore
|
||||
assert not layout.cells[0].properties
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# type: ignore
|
||||
# mypy: disable-error-code="union-attr"
|
||||
from typing import IO
|
||||
from io import BytesIO
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# type: ignore
|
||||
# mypy: disable-error-code="union-attr"
|
||||
from typing import IO
|
||||
from io import BytesIO
|
||||
|
||||
@ -182,7 +182,7 @@ def test_file_1() -> None:
|
||||
else:
|
||||
assert gg.half_width == 12, msg
|
||||
|
||||
assert len(gg.point_list) == 3, msg
|
||||
assert len(gg.point_list) == 3, msg # type: ignore
|
||||
assert_equal(gg.point_list, [[150, 0], [0, 50], [-50, 0]], err_msg=msg)
|
||||
|
||||
if ii >= 4:
|
||||
|
@ -1,5 +1,5 @@
|
||||
# type: ignore
|
||||
from typing import Tuple, IO, cast, List
|
||||
# mypy: disable-error-code="union-attr"
|
||||
from typing import IO, cast
|
||||
from io import BytesIO
|
||||
|
||||
from numpy.testing import assert_equal
|
||||
@ -22,7 +22,7 @@ def base_tests(layout: OasisLayout) -> None:
|
||||
assert not layout.layers
|
||||
|
||||
|
||||
def write_rectangle(buf: IO[bytes], pos: Tuple[int, int] = (300, -400)) -> None:
|
||||
def write_rectangle(buf: IO[bytes], pos: tuple[int, int] = (300, -400)) -> None:
|
||||
write_uint(buf, 20) # RECTANGLE record
|
||||
write_byte(buf, 0b0111_1011) # SWHX_YRDL
|
||||
write_uint(buf, 1) # layer
|
||||
@ -174,7 +174,7 @@ def test_file_1() -> None:
|
||||
assert not layout.cells[1].properties
|
||||
assert not layout.cells[1].geometry
|
||||
|
||||
geometry = cast(List[Rectangle], layout.cells[0].geometry)
|
||||
geometry = cast(list[Rectangle], layout.cells[0].geometry)
|
||||
assert len(geometry) == 1
|
||||
assert geometry[0].layer == 1
|
||||
assert geometry[0].datatype == 2
|
||||
@ -843,7 +843,7 @@ def test_file_8() -> None:
|
||||
assert not layout.cells[2].properties
|
||||
assert not layout.cells[2].placements
|
||||
|
||||
geometry = cast(List[Rectangle], layout.cells[2].geometry)
|
||||
geometry = cast(list[Rectangle], layout.cells[2].geometry)
|
||||
assert len(geometry) == 1
|
||||
assert geometry[0].layer == 1
|
||||
assert geometry[0].datatype == 2
|
||||
|
@ -1,4 +1,4 @@
|
||||
# type: ignore
|
||||
# mypy: disable-error-code="union-attr, arg-type"
|
||||
from typing import IO
|
||||
from io import BytesIO
|
||||
|
||||
@ -445,7 +445,7 @@ def test_file_3() -> None:
|
||||
for ii, gg in enumerate(geometry):
|
||||
msg = f'Fail on polygon {ii}'
|
||||
assert len(gg.properties) == 1, msg
|
||||
assert gg.properties[0].name == 0, msg
|
||||
assert gg.properties[0].name == 0, msg # type: ignore
|
||||
assert len(gg.properties[0].values) == 1, msg
|
||||
assert gg.properties[0].values[0] * 5 == 1, msg
|
||||
assert gg.properties[0].values[0] * 5 == 1, msg # type: ignore
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# type: ignore
|
||||
# mypy: disable-error-code="union-attr, index, arg-type"
|
||||
from typing import IO
|
||||
from io import BytesIO
|
||||
|
||||
@ -28,7 +28,7 @@ def write_file_common(buf: IO[bytes], variant: int) -> IO[bytes]:
|
||||
"""
|
||||
include_repetitions = variant in (2, 5)
|
||||
|
||||
def var_byte(buf, byte):
|
||||
def var_byte(buf: IO[bytes], byte: int) -> None:
|
||||
if include_repetitions:
|
||||
byte |= 0b0100
|
||||
write_byte(buf, byte)
|
||||
|
@ -1,4 +1,4 @@
|
||||
# type: ignore
|
||||
# mypy: disable-error-code="union-attr"
|
||||
from typing import IO
|
||||
from io import BytesIO
|
||||
|
||||
@ -267,7 +267,7 @@ def test_file_2() -> None:
|
||||
prop = gg.properties[0]
|
||||
|
||||
assert prop.name == 0, msg
|
||||
assert len(prop.values) == 1, msg
|
||||
assert prop.values[0].numerator == 1, msg
|
||||
assert prop.values[0].denominator == 5, msg
|
||||
assert len(prop.values) == 1, msg # type: ignore
|
||||
assert prop.values[0].numerator == 1, msg # type: ignore
|
||||
assert prop.values[0].denominator == 5, msg # type: ignore
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# type: ignore
|
||||
# mypy: disable-error-code="union-attr, index"
|
||||
from typing import IO
|
||||
from io import BytesIO
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
# type: ignore
|
||||
# mypy: disable-error-code="union-attr"
|
||||
from typing import IO
|
||||
from io import BytesIO
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user