Skip to content

Commit 1c98ac7

Browse files
committed
fix(typing): improve accuracy of type propagation for collections
1 parent b1d1a25 commit 1c98ac7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/ansys/dpf/core/collection.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@
3333
from ansys.dpf.core.common import create_dpf_instance
3434

3535
TYPE = TypeVar("TYPE")
36+
SKYE = TypeVar("SKYE")
3637

3738

3839
# Explicit Generic[TYPE] helps some type checkers Collection as a generic.
39-
class Collection(CollectionBase[TYPE], Generic[TYPE]):
40+
class Collection(CollectionBase[TYPE]):
4041
"""Represents a collection of dpf objects organised by label spaces.
4142
4243
Parameters
@@ -126,7 +127,7 @@ def add_entry(self, label_space, entry):
126127
return super()._add_entry(label_space, Any.new_from(entry, server=self._server))
127128

128129
@classmethod
129-
def collection_factory(cls, subtype: TYPE) -> Type[Collection[TYPE]]:
130+
def collection_factory(cls, subtype: Type[SKYE]) -> Type[Collection[SKYE]]:
130131
"""Create classes deriving from Collection at runtime for a given subtype.
131132
132133
This factory method dynamically creates a new class that inherits from Collection

0 commit comments

Comments
 (0)