Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-111681: Fix doctests in typing.rst and remove unused imports #111682

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions 8 Doc/library/typing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1954,7 +1954,7 @@ without the dedicated syntax, as documented below.

.. doctest::

>>> from typing import ParamSpec
>>> from typing import ParamSpec, get_origin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind the change you're making here. But the reason why this doesn't currently fail when Sphinx runs our doctests in CI is because of this, which is run before every doctest block:

.. testsetup:: *
import typing
from dataclasses import dataclass
from typing import *

>>> P = ParamSpec("P")
>>> get_origin(P.args) is P
True
Expand Down Expand Up @@ -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.

Expand Down
5 changes: 2 additions & 3 deletions 5 Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
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

Expand Down Expand Up @@ -45,7 +44,7 @@
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

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.