From 53a48b8c0e3f276f83d8d996603f1de8a723c8ea Mon Sep 17 00:00:00 2001 From: wchistow Date: Tue, 11 Apr 2023 12:23:35 +0300 Subject: [PATCH 1/3] Add more correct type annotations for `tomllib` --- stdlib/tomllib.pyi | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/stdlib/tomllib.pyi b/stdlib/tomllib.pyi index 3a6ce93f87e1..fa5bbdacdd80 100644 --- a/stdlib/tomllib.pyi +++ b/stdlib/tomllib.pyi @@ -1,10 +1,14 @@ from _typeshed import SupportsRead from collections.abc import Callable -from typing import Any +from datetime import datetime, date, time +from typing import Any, TypeAlias __all__ = ("loads", "load", "TOMLDecodeError") class TOMLDecodeError(ValueError): ... -def load(__fp: SupportsRead[bytes], *, parse_float: Callable[[str], Any] = ...) -> dict[str, Any]: ... -def loads(__s: str, *, parse_float: Callable[[str], Any] = ...) -> dict[str, Any]: ... +TOMLValue: TypeAlias = int | float | str | bool | list['TOMLValue'] | \ + dict['TOMLValue', 'TOMLValue'] | datetime | date | time + +def load(__fp: SupportsRead[bytes], *, parse_float: Callable[[str], Any] = ...) -> dict[str, TOMLValue]: ... +def loads(__s: str, *, parse_float: Callable[[str], Any] = ...) -> dict[str, TOMLValue]: ... From 3d1dda933f9058c75966486b840248360f1d328e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 11 Apr 2023 09:29:17 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stdlib/tomllib.pyi | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/stdlib/tomllib.pyi b/stdlib/tomllib.pyi index fa5bbdacdd80..ae005814c8aa 100644 --- a/stdlib/tomllib.pyi +++ b/stdlib/tomllib.pyi @@ -1,14 +1,13 @@ from _typeshed import SupportsRead from collections.abc import Callable -from datetime import datetime, date, time +from datetime import date, datetime, time from typing import Any, TypeAlias __all__ = ("loads", "load", "TOMLDecodeError") class TOMLDecodeError(ValueError): ... -TOMLValue: TypeAlias = int | float | str | bool | list['TOMLValue'] | \ - dict['TOMLValue', 'TOMLValue'] | datetime | date | time +TOMLValue: TypeAlias = int | float | str | bool | list["TOMLValue"] | dict["TOMLValue", "TOMLValue"] | datetime | date | time def load(__fp: SupportsRead[bytes], *, parse_float: Callable[[str], Any] = ...) -> dict[str, TOMLValue]: ... def loads(__s: str, *, parse_float: Callable[[str], Any] = ...) -> dict[str, TOMLValue]: ... From d82f697cf2045d0c84c546c380320dfe35fbef95 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Tue, 11 Apr 2023 11:54:18 +0100 Subject: [PATCH 3/3] CI fixes --- stdlib/tomllib.pyi | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/stdlib/tomllib.pyi b/stdlib/tomllib.pyi index ae005814c8aa..7188f03b248c 100644 --- a/stdlib/tomllib.pyi +++ b/stdlib/tomllib.pyi @@ -1,13 +1,14 @@ from _typeshed import SupportsRead from collections.abc import Callable from datetime import date, datetime, time -from typing import Any, TypeAlias +from typing import Any +from typing_extensions import TypeAlias __all__ = ("loads", "load", "TOMLDecodeError") class TOMLDecodeError(ValueError): ... -TOMLValue: TypeAlias = int | float | str | bool | list["TOMLValue"] | dict["TOMLValue", "TOMLValue"] | datetime | date | time +_TOMLValue: TypeAlias = int | float | str | bool | list[_TOMLValue] | dict[_TOMLValue, _TOMLValue] | datetime | date | time -def load(__fp: SupportsRead[bytes], *, parse_float: Callable[[str], Any] = ...) -> dict[str, TOMLValue]: ... -def loads(__s: str, *, parse_float: Callable[[str], Any] = ...) -> dict[str, TOMLValue]: ... +def load(__fp: SupportsRead[bytes], *, parse_float: Callable[[str], Any] = ...) -> dict[str, _TOMLValue]: ... +def loads(__s: str, *, parse_float: Callable[[str], Any] = ...) -> dict[str, _TOMLValue]: ...