From af31b21cd2a032ea83a3a77eca2baa8f7a0c8b88 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 25 Apr 2022 19:53:26 -0700 Subject: [PATCH 1/2] decimal: kwargs to localcontext() python/cpython#32242 --- stdlib/_decimal.pyi | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/stdlib/_decimal.pyi b/stdlib/_decimal.pyi index fdeca8f7c42f..b2c53d4d4515 100644 --- a/stdlib/_decimal.pyi +++ b/stdlib/_decimal.pyi @@ -52,7 +52,18 @@ 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: ... From 466b9334bb7d52c0f6e7f8c37d796e08b306491d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 26 Apr 2022 02:54:48 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/_decimal.pyi | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/stdlib/_decimal.pyi b/stdlib/_decimal.pyi index b2c53d4d4515..a259058ee163 100644 --- a/stdlib/_decimal.pyi +++ b/stdlib/_decimal.pyi @@ -52,16 +52,21 @@ class FloatOperation(DecimalException, TypeError): ... def setcontext(__context: Context) -> None: ... def getcontext() -> Context: ... + if sys.version_info >= (3, 11): - def localcontext(ctx: Context | None = ..., *, + 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: ... + 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: ...