Skip to content

Commit

Permalink
fixing spockTuner class based on new underlying functions. adding in …
Browse files Browse the repository at this point in the history
…stubs for type hinting
  • Loading branch information
ncilfone committed Jan 14, 2022
1 parent 8ddae3c commit fe8e089
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions spock/addons/tune/config.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from typing import Any, Callable, Tuple, TypeVar, Union, overload

from attr import attrib, field

_T = TypeVar("_T")
_C = TypeVar("_C", bound=type)

# Note: from here
# https://github.com/python-attrs/attrs/blob/main/src/attr/__init__.pyi

# Static type inference support via __dataclass_transform__ implemented as per:
# https://github.com/microsoft/pyright/blob/main/specs/dataclass_transforms.md
# This annotation must be applied to all overloads of "spock_attr"

# NOTE: This is a typing construct and does not exist at runtime. Extensions
# wrapping attrs decorators should declare a separate __dataclass_transform__
# signature in the extension module using the specification linked above to
# provide pyright support -- this currently doesn't work in PyCharm
def __dataclass_transform__(
*,
eq_default: bool = True,
order_default: bool = False,
kw_only_default: bool = False,
field_descriptors: Tuple[Union[type, Callable[..., Any]], ...] = (()),
) -> Callable[[_T], _T]: ...
@overload
@__dataclass_transform__(kw_only_default=True, field_descriptors=(attrib, field))
def _spock_tune(
maybe_cls: _C,
kw_only: bool = True,
make_init: bool = True,
) -> _C: ...
@overload
@__dataclass_transform__(kw_only_default=True, field_descriptors=(attrib, field))
def _spock_tune(
maybe_cls: None = ...,
kw_only: bool = True,
make_init: bool = True,
) -> Callable[[_C], _C]: ...

0 comments on commit fe8e089

Please sign in to comment.