mirror of
https://github.com/gumyr/build123d.git
synced 2025-12-06 02:30:55 -08:00
Update type signature for component getters
This commit is contained in:
parent
17f16b6b97
commit
dce0c5dc1b
1 changed files with 9 additions and 4 deletions
|
|
@ -50,7 +50,7 @@ import functools
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from itertools import product
|
from itertools import product
|
||||||
from math import sqrt, cos, pi
|
from math import sqrt, cos, pi
|
||||||
from typing import Any, cast, overload, Type, TypeVar
|
from typing import Any, cast, overload, Protocol, Type, TypeVar
|
||||||
|
|
||||||
from collections.abc import Callable, Iterable
|
from collections.abc import Callable, Iterable
|
||||||
from typing_extensions import Self
|
from typing_extensions import Self
|
||||||
|
|
@ -1341,11 +1341,16 @@ class WorkplaneList:
|
||||||
|
|
||||||
# Type variable representing the return type of the wrapped function
|
# Type variable representing the return type of the wrapped function
|
||||||
T2 = TypeVar("T2")
|
T2 = TypeVar("T2")
|
||||||
|
T2_covar = TypeVar("T2_covar", covariant=True)
|
||||||
|
|
||||||
|
|
||||||
|
class ContextComponentGetter(Protocol[T2_covar]):
|
||||||
|
def __call__(self, select: Select = Select.ALL) -> T2_covar: ...
|
||||||
|
|
||||||
|
|
||||||
def __gen_context_component_getter(
|
def __gen_context_component_getter(
|
||||||
func: Callable[[Builder, Select], T2]
|
func: Callable[[Builder, Select], T2],
|
||||||
) -> Callable[[Select], T2]:
|
) -> ContextComponentGetter[T2]:
|
||||||
"""
|
"""
|
||||||
Wraps a Builder method to automatically provide the Builder context.
|
Wraps a Builder method to automatically provide the Builder context.
|
||||||
|
|
||||||
|
|
@ -1360,7 +1365,7 @@ def __gen_context_component_getter(
|
||||||
a `Select` instance as its second argument.
|
a `Select` instance as its second argument.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Callable[[Select], T2]: A callable that takes only a `Select` argument and
|
ContextComponentGetter[T2]: A callable that takes only a `Select` argument and
|
||||||
internally retrieves the Builder context to call the original method.
|
internally retrieves the Builder context to call the original method.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue