FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-111681: Fix doctests in `typing.rst` and remove unused imports by sobolevn · Pull Request #111682 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
8 changes: 4 additions & 4 deletions Doc/library/typing.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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 Lib/test/test_typing.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL