fix more type issues

This commit is contained in:
Jan Petykiewicz 2023-01-22 22:16:09 -08:00 • committed by jan
commit db9b39dbc0
11 changed files with 54 additions and 34 deletions

View file

@ -6,6 +6,9 @@ from ..utils import annotations_t
from ..error import MasqueError
_empty_slots = () # Workaround to get mypy to ignore intentionally empty slots for superclass
T = TypeVar('T', bound='Annotatable')
I = TypeVar('I', bound='AnnotatableImpl')
@ -33,7 +36,7 @@ class AnnotatableImpl(Annotatable, metaclass=ABCMeta):
"""
Simple implementation of `Annotatable`.
"""
__slots__ = ()
__slots__ = _empty_slots
_annotations: annotations_t
""" Dictionary storing annotation name/value pairs """
@ -46,7 +49,7 @@ class AnnotatableImpl(Annotatable, metaclass=ABCMeta):
return self._annotations
@annotations.setter
def annotations(self, annotations: annotations_t):
def annotations(self, annotations: annotations_t) -> None:
if not isinstance(annotations, dict):
raise MasqueError(f'annotations expected dict, got {type(annotations)}')
self._annotations = annotations

View file

@ -4,6 +4,9 @@ from abc import ABCMeta, abstractmethod
from ..utils import layer_t
_empty_slots = () # Workaround to get mypy to ignore intentionally empty slots for superclass
T = TypeVar('T', bound='Layerable')
I = TypeVar('I', bound='LayerableImpl')
@ -50,7 +53,7 @@ class LayerableImpl(Layerable, metaclass=ABCMeta):
"""
Simple implementation of Layerable
"""
__slots__ = ()
__slots__ = _empty_slots
_layer: layer_t
""" Layer number, pair, or name """

View file

@ -9,6 +9,9 @@ from numpy.typing import NDArray, ArrayLike
from ..error import MasqueError
_empty_slots = () # Workaround to get mypy to ignore intentionally empty slots for superclass
T = TypeVar('T', bound='Positionable')
I = TypeVar('I', bound='PositionableImpl')
@ -85,7 +88,7 @@ class PositionableImpl(Positionable, metaclass=ABCMeta):
"""
Simple implementation of Positionable
"""
__slots__ = ()
__slots__ = _empty_slots
_offset: NDArray[numpy.float64]
""" `[x_offset, y_offset]` """
@ -108,7 +111,7 @@ class PositionableImpl(Positionable, metaclass=ABCMeta):
if val.size != 2:
raise MasqueError('Offset must be convertible to size-2 ndarray')
self._offset = val.flatten()
self._offset = val.flatten() # type: ignore
'''
---- Methods

View file

@ -4,6 +4,9 @@ from abc import ABCMeta, abstractmethod
from ..error import MasqueError
_empty_slots = () # Workaround to get mypy to ignore intentionally empty slots for superclass
if TYPE_CHECKING:
from ..repetition import Repetition
@ -55,7 +58,7 @@ class RepeatableImpl(Repeatable, metaclass=ABCMeta):
"""
Simple implementation of `Repeatable`
"""
__slots__ = ()
__slots__ = _empty_slots
_repetition: Optional['Repetition']
""" Repetition object, or None (single instance only) """

View file

@ -10,6 +10,9 @@ from ..error import MasqueError
from ..utils import is_scalar, rotation_matrix_2d
_empty_slots = () # Workaround to get mypy to ignore intentionally empty slots for superclass
T = TypeVar('T', bound='Rotatable')
I = TypeVar('I', bound='RotatableImpl')
P = TypeVar('P', bound='Pivotable')
@ -43,7 +46,7 @@ class RotatableImpl(Rotatable, metaclass=ABCMeta):
"""
Simple implementation of `Rotatable`
"""
__slots__ = ()
__slots__ = _empty_slots
_rotation: float
""" rotation for the object, radians counterclockwise """

View file

@ -5,6 +5,9 @@ from ..error import MasqueError
from ..utils import is_scalar
_empty_slots = () # Workaround to get mypy to ignore intentionally empty slots for superclass
T = TypeVar('T', bound='Scalable')
I = TypeVar('I', bound='ScalableImpl')
@ -36,7 +39,7 @@ class ScalableImpl(Scalable, metaclass=ABCMeta):
"""
Simple implementation of Scalable
"""
__slots__ = ()
__slots__ = _empty_slots
_scale: float
""" scale factor for the entity """