Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libsass: Use TypeVarTuple in sass.SassFunction #11132

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions stubs/libsass/sass.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import enum
from _typeshed import ConvertibleToFloat, SupportsKeysAndGetItem
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence, Set as AbstractSet
from typing import Any, Generic, Literal, NamedTuple, TypeVar, overload, type_check_only
from typing_extensions import ParamSpec, Self, TypeAlias
from typing_extensions import Self, TypeAlias, TypeVarTuple, Unpack

_T = TypeVar("_T")
_KT = TypeVar("_KT")
_VT_co = TypeVar("_VT_co", covariant=True)
_P = ParamSpec("_P")
_Ts = TypeVarTuple("_Ts")
_Mode: TypeAlias = Literal["string", "filename", "dirname"]
_OutputStyle: TypeAlias = Literal["nested", "expanded", "compact", "compressed"]
_CustomFunctions: TypeAlias = Mapping[str, Callable[..., Any]] | Sequence[Callable[..., Any]] | AbstractSet[Callable[..., Any]]
Expand All @@ -25,20 +25,18 @@ MODES: frozenset[_Mode]
class CompileError(ValueError):
def __init__(self, msg: str) -> None: ...

# _P needs to be positional only and can't contain varargs, but there is no way to express that
# the arguments also need
class SassFunction(Generic[_P, _T]):
class SassFunction(Generic[Unpack[_Ts], _T]):
@classmethod
def from_lambda(cls, name: str, lambda_: Callable[_P, _T]) -> SassFunction[_P, _T]: ...
def from_lambda(cls, name: str, lambda_: Callable[[Unpack[_Ts]], _T]) -> SassFunction[Unpack[_Ts], _T]: ...
@classmethod
def from_named_function(cls, function: Callable[_P, _T]) -> SassFunction[_P, _T]: ...
def from_named_function(cls, function: Callable[[Unpack[_Ts]], _T]) -> SassFunction[Unpack[_Ts], _T]: ...
name: str
arguments: tuple[str, ...]
callable_: Callable[_P, _T]
def __init__(self, name: str, arguments: Sequence[str], callable_: Callable[_P, _T]) -> None: ...
callable_: Callable[[Unpack[_Ts]], _T]
def __init__(self, name: str, arguments: Sequence[str], callable_: Callable[[Unpack[_Ts]], _T]) -> None: ...
@property
def signature(self) -> str: ...
def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _T: ...
def __call__(self, *args: Unpack[_Ts]) -> _T: ...

@overload
def compile(
Expand Down
Loading