mercurial/thirdparty/attr/setters.pyi
author Pierre-Yves David <pierre-yves.david@octobus.net>
Thu, 02 Feb 2023 17:28:30 +0100
changeset 50615 b2ec43d552d4
parent 49761 e1c586b9a43c
permissions -rw-r--r--
safehasattr: pass attribute name as string instead of bytes This is a step toward replacing `util.safehasattr` usage with plain `hasattr`. The builtin function behave poorly in Python2 but this was fixed in Python3. These change are done one by one as they tend to have a small odd to trigger puzzling breackage.

from typing import Any, NewType, NoReturn, TypeVar, cast

from . import Attribute, _OnSetAttrType

_T = TypeVar("_T")

def frozen(
    instance: Any, attribute: Attribute[Any], new_value: Any
) -> NoReturn: ...
def pipe(*setters: _OnSetAttrType) -> _OnSetAttrType: ...
def validate(instance: Any, attribute: Attribute[_T], new_value: _T) -> _T: ...

# convert is allowed to return Any, because they can be chained using pipe.
def convert(
    instance: Any, attribute: Attribute[Any], new_value: Any
) -> Any: ...

_NoOpType = NewType("_NoOpType", object)
NO_OP: _NoOpType