From: Nikita Sobolev Date: Fri, 3 Nov 2023 12:23:33 +0000 (+0300) Subject: gh-111681: minor fixes to typing doctests; remove unused imports in `test_typing... X-Git-Tag: v3.13.0a2~207 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ccc8caa8587103c4ccf617ba106cef63344504dd;p=thirdparty%2FPython%2Fcpython.git gh-111681: minor fixes to typing doctests; remove unused imports in `test_typing` (#111682) Co-authored-by: Alex Waygood --- diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index bdff2bb776d8..f82f53514a71 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -1954,7 +1954,7 @@ without the dedicated syntax, as documented below. .. doctest:: - >>> from typing import ParamSpec + >>> from typing import ParamSpec, get_origin >>> P = ParamSpec("P") >>> get_origin(P.args) is P True @@ -3059,14 +3059,14 @@ Introspection helpers Return the set of members defined in a :class:`Protocol`. - :: + .. doctest:: >>> from typing import Protocol, get_protocol_members >>> class P(Protocol): ... def a(self) -> str: ... ... b: int - >>> get_protocol_members(P) - frozenset({'a', 'b'}) + >>> get_protocol_members(P) == frozenset({'a', 'b'}) + True Raise :exc:`TypeError` for arguments that are not Protocols. diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 7f60bf4bbc1e..9dd637b97476 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -9,8 +9,7 @@ import itertools import pickle import re import sys -import warnings -from unittest import TestCase, main, skipUnless, skip +from unittest import TestCase, main, skip from unittest.mock import patch from copy import copy, deepcopy @@ -45,7 +44,7 @@ import typing import weakref import types -from test.support import import_helper, captured_stderr, cpython_only +from test.support import captured_stderr, cpython_only from test import mod_generics_cache from test import _typed_dict_helper