Skip to content

Commit

Permalink
fix: More accurate type hints for Python @planning_entity
Browse files Browse the repository at this point in the history
  • Loading branch information
luxaritas authored Dec 11, 2024
1 parent e474d86 commit 71f8786
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions python/python-core/src/main/python/domain/_annotations.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from _jpyinterpreter import JavaAnnotation
from enum import Enum
from jpype import JImplements, JOverride, JClass
from typing import Union, List, Callable, Type, TypeVar
from typing import Union, List, Callable, Type, TypeVar, overload

from ._variable_listener import VariableListener
from .._timefold_java_interop import ensure_init

Solution_ = TypeVar('Solution_')
Entity_ = TypeVar('Entity_')


class PlanningId(JavaAnnotation):
Expand Down Expand Up @@ -741,9 +742,13 @@ def __init__(self, delegate):
def accept(self, solution, entity):
return self.delegate(solution, entity)


def planning_entity(entity_class: Type = None, /, *, pinning_filter: Callable = None) -> Union[Type,
Callable[[Type], Type]]:
@overload
def planning_entity(entity_class: Type[Entity_]) -> Type[Entity_]:
...
@overload
def planning_entity(pinning_filter: Callable = None) -> Callable[[Type[Entity_]], Type[Entity_]]:
...
def planning_entity(entity_class = None, /, *, pinning_filter = None):
"""
Specifies that the class is a planning entity.
There are two types of entities:
Expand Down

0 comments on commit 71f8786

Please sign in to comment.