From 2299c43860c7115fabfd14ad854144e2ef20e132 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 26 Apr 2022 04:19:29 -0700 Subject: [PATCH] decimal: kwargs to localcontext() (#7686) --- stdlib/_decimal.pyi | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/stdlib/_decimal.pyi b/stdlib/_decimal.pyi index fdeca8f7c..a259058ee 100644 --- a/stdlib/_decimal.pyi +++ b/stdlib/_decimal.pyi @@ -52,7 +52,23 @@ class FloatOperation(DecimalException, TypeError): ... def setcontext(__context: Context) -> None: ... def getcontext() -> Context: ... -def localcontext(ctx: Context | None = ...) -> _ContextManager: ... + +if sys.version_info >= (3, 11): + def localcontext( + ctx: Context | None = ..., + *, + prec: int | None = ..., + rounding: str | None = ..., + Emin: int | None = ..., + Emax: int | None = ..., + capitals: int | None = ..., + clamp: int | None = ..., + traps: dict[_TrapType, bool] | None = ..., + flags: dict[_TrapType, bool] | None = ..., + ) -> _ContextManager: ... + +else: + def localcontext(ctx: Context | None = ...) -> _ContextManager: ... class Decimal: def __new__(cls: type[Self], value: _DecimalNew = ..., context: Context | None = ...) -> Self: ...