From edf41ae5e239d92a5c063179842062f2bc368ed8 Mon Sep 17 00:00:00 2001 From: M Bussonnier Date: Wed, 7 Feb 2024 11:24:21 -0800 Subject: [PATCH] Update type of Formatter.convert_field (missing `|None`) (#11377) From the source it expects that the second parameter (conversion), can be None: ```python def convert_field(self, value, conversion): # do any conversion on the resulting object if conversion is None: return value ... ``` Since at least 17 years according to git blame, as None is refered as early as 11529195cae2438a3ac003babcb1b11af67c4037 And still present in main branch: https://github.com/python/cpython/blob/ef3ceab09d2d0959c343c662461123d5b0e0b64b/Lib/string.py --- stdlib/string.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/string.pyi b/stdlib/string.pyi index 1a875a071..8b60243f2 100644 --- a/stdlib/string.pyi +++ b/stdlib/string.pyi @@ -80,4 +80,4 @@ class Formatter: def get_value(self, key: int | str, args: Sequence[Any], kwargs: Mapping[str, Any]) -> Any: ... def check_unused_args(self, used_args: set[int | str], args: Sequence[Any], kwargs: Mapping[str, Any]) -> None: ... def format_field(self, value: Any, format_spec: str) -> Any: ... - def convert_field(self, value: Any, conversion: str) -> Any: ... + def convert_field(self, value: Any, conversion: str | None) -> Any: ...