From 7829376a6a1eb1d9fd016a3014bd9c1a36853b33 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 5 Mar 2025 12:51:54 +0100 Subject: [PATCH 1/3] Change links from typing.readthedocs.io to typing.python.org --- .../parsing/pep_banner_directive.py | 24 +++++++++---------- peps/conf.py | 2 +- peps/pep-0012.rst | 2 +- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/pep_sphinx_extensions/pep_processor/parsing/pep_banner_directive.py b/pep_sphinx_extensions/pep_processor/parsing/pep_banner_directive.py index ff0ca96f86f..275afb2103e 100644 --- a/pep_sphinx_extensions/pep_processor/parsing/pep_banner_directive.py +++ b/pep_sphinx_extensions/pep_processor/parsing/pep_banner_directive.py @@ -6,7 +6,7 @@ from docutils.parsers import rst PYPA_SPEC_BASE_URL = "https://packaging.python.org/en/latest/specifications/" -TYPING_SPEC_BASE_URL = "https://typing.readthedocs.io/en/latest/spec/" +TYPING_SPEC_BASE_URL = "https://typing.python.org/en/latest/spec/" class PEPBanner(rst.Directive): @@ -26,16 +26,16 @@ class PEPBanner(rst.Directive): css_classes = [] def run(self) -> list[nodes.admonition]: - if self.arguments: link_content = self.arguments[0] - pre_text = self.admonition_pre_template.format( - link_content=link_content) + pre_text = self.admonition_pre_template.format(link_content=link_content) else: pre_text = self.admonition_pre_text - close_button_node = nodes.paragraph('', '', nodes.Text('×'), classes=['close-button']) - close_button_node['classes'].append('close-button') + close_button_node = nodes.paragraph( + "", "", nodes.Text("×"), classes=["close-button"] + ) + close_button_node["classes"].append("close-button") pre_text_node = nodes.paragraph(pre_text) pre_text_node.line = self.lineno @@ -50,13 +50,13 @@ def run(self) -> list[nodes.admonition]: source_lines = [pre_text] + list(self.content or []) + [post_text] admonition_node = self.admonition_class( - "\n".join(source_lines), classes=["pep-banner"] + self.css_classes) + "\n".join(source_lines), classes=["pep-banner"] + self.css_classes + ) admonition_node.append(pre_text_node) admonition_node.append(close_button_node) if self.content: - self.state.nested_parse( - self.content, self.content_offset, admonition_node) + self.state.nested_parse(self.content, self.content_offset, admonition_node) admonition_node.append(post_text_node) return [admonition_node] @@ -74,9 +74,7 @@ class CanonicalDocBanner(PEPBanner): "This PEP is a historical document. " "The up-to-date, canonical documentation can now be found elsewhere." ) - admonition_post_text = ( - "See :pep:`1` for how to propose changes." - ) + admonition_post_text = "See :pep:`1` for how to propose changes." css_classes = ["canonical-doc", "sticky-banner"] @@ -113,7 +111,7 @@ class CanonicalTypingSpecBanner(PEPBanner): admonition_pre_text = admonition_pre_template admonition_post_text = ( "See the `typing specification update process " - "`__ " + "`__ " "for how to propose changes to the typing spec." ) css_classes = ["canonical-typing-spec", "sticky-banner"] diff --git a/peps/conf.py b/peps/conf.py index 0bad14e819f..a3de44a3c5d 100644 --- a/peps/conf.py +++ b/peps/conf.py @@ -75,7 +75,7 @@ "py3.14": ("https://docs.python.org/3.14/", None), "python": ("https://docs.python.org/3/", None), "trio": ("https://trio.readthedocs.io/en/latest/", None), - "typing": ("https://typing.readthedocs.io/en/latest/", None), + "typing": ("https://typing.python.org/en/latest/", None), } intersphinx_disabled_reftypes = [] diff --git a/peps/pep-0012.rst b/peps/pep-0012.rst index cb52ba4301e..4e94e6f2d36 100644 --- a/peps/pep-0012.rst +++ b/peps/pep-0012.rst @@ -656,7 +656,7 @@ You can use to other Sphinx sites, such as the `Python documentation `_ `packaging.python.org `_, -and `typing.readthedocs.io `_, +and `typing.python.org `_, to easily cross-reference pages, sections and Python/C objects. For example, From ab9733db1be6bd308ffbd878c2eea53f5d008370 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Wed, 5 Mar 2025 16:17:22 +0000 Subject: [PATCH 2/3] Revert unrelated changes --- .../parsing/pep_banner_directive.py | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/pep_sphinx_extensions/pep_processor/parsing/pep_banner_directive.py b/pep_sphinx_extensions/pep_processor/parsing/pep_banner_directive.py index 275afb2103e..5584719dd39 100644 --- a/pep_sphinx_extensions/pep_processor/parsing/pep_banner_directive.py +++ b/pep_sphinx_extensions/pep_processor/parsing/pep_banner_directive.py @@ -26,16 +26,16 @@ class PEPBanner(rst.Directive): css_classes = [] def run(self) -> list[nodes.admonition]: + if self.arguments: link_content = self.arguments[0] - pre_text = self.admonition_pre_template.format(link_content=link_content) + pre_text = self.admonition_pre_template.format( + link_content=link_content) else: pre_text = self.admonition_pre_text - close_button_node = nodes.paragraph( - "", "", nodes.Text("×"), classes=["close-button"] - ) - close_button_node["classes"].append("close-button") + close_button_node = nodes.paragraph('', '', nodes.Text('×'), classes=['close-button']) + close_button_node['classes'].append('close-button') pre_text_node = nodes.paragraph(pre_text) pre_text_node.line = self.lineno @@ -50,13 +50,13 @@ def run(self) -> list[nodes.admonition]: source_lines = [pre_text] + list(self.content or []) + [post_text] admonition_node = self.admonition_class( - "\n".join(source_lines), classes=["pep-banner"] + self.css_classes - ) + "\n".join(source_lines), classes=["pep-banner"] + self.css_classes) admonition_node.append(pre_text_node) admonition_node.append(close_button_node) if self.content: - self.state.nested_parse(self.content, self.content_offset, admonition_node) + self.state.nested_parse( + self.content, self.content_offset, admonition_node) admonition_node.append(post_text_node) return [admonition_node] @@ -74,7 +74,9 @@ class CanonicalDocBanner(PEPBanner): "This PEP is a historical document. " "The up-to-date, canonical documentation can now be found elsewhere." ) - admonition_post_text = "See :pep:`1` for how to propose changes." + admonition_post_text = ( + "See :pep:`1` for how to propose changes." + ) css_classes = ["canonical-doc", "sticky-banner"] From 3a3b9c28deb48679fe217535d8fe6c1d8edc7ed8 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Wed, 5 Mar 2025 16:18:20 +0000 Subject: [PATCH 3/3] Update all links --- peps/pep-0688.rst | 2 +- peps/pep-0692.rst | 2 +- peps/pep-0728.rst | 12 ++++++------ peps/pep-0729.rst | 2 +- peps/pep-0767.rst | 10 +++++----- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/peps/pep-0688.rst b/peps/pep-0688.rst index 38cb9d4fad7..2197334753c 100644 --- a/peps/pep-0688.rst +++ b/peps/pep-0688.rst @@ -349,7 +349,7 @@ How to Teach This ================= We will add notes pointing to ``collections.abc.Buffer`` in appropriate places in the -documentation, such as `typing.readthedocs.io `__ +documentation, such as `typing.python.org `__ and the `mypy cheat sheet `__. Type checkers may provide additional pointers in their error messages. For example, when they encounter a buffer object being passed to a function that diff --git a/peps/pep-0692.rst b/peps/pep-0692.rst index 23f192d2664..9dda404d22a 100644 --- a/peps/pep-0692.rst +++ b/peps/pep-0692.rst @@ -457,7 +457,7 @@ This PEP could be linked in the ``typing`` module's documentation. Moreover, a new section on using ``Unpack`` could be added to the aforementioned docs. Similar sections could be also added to the `mypy documentation `_ and the -`typing RTD documentation `_. +`typing documentation `_. Reference Implementation ======================== diff --git a/peps/pep-0728.rst b/peps/pep-0728.rst index 0f645690404..e81d868a27b 100644 --- a/peps/pep-0728.rst +++ b/peps/pep-0728.rst @@ -160,7 +160,7 @@ assignable to the ``extra_items`` argument. There are some advantages to this approach: - We can build on top of the `assignability rules defined in the typing spec - `__, + `__, where ``extra_items`` can be treated as a pseudo-item. - There is no need to introduce a grammar change to specify the type of the @@ -182,7 +182,7 @@ If ``extra_items`` is specified, extra items are treated as :ref:`non-required ` items matching the ``extra_items`` argument, whose keys are allowed when determining `supported and unsupported operations -`__. +`__. The ``extra_items`` Class Parameter ----------------------------------- @@ -306,9 +306,9 @@ It is an error to use ``Required[]`` or ``NotRequired[]`` with ``extra_items``. ``total=False`` and ``total=True`` have no effect on ``extra_items`` itself. The extra items are non-required, regardless of the `totality -`__ of the +`__ of the TypedDict. `Operations -`__ +`__ that are available to ``NotRequired`` items should also be available to the extra items:: @@ -356,7 +356,7 @@ Inheritance ``extra_items`` is inherited in a similar way as a regular ``key: value_type`` item. As with the other keys, the `inheritance rules -`__ +`__ and :ref:`Read-only Items ` inheritance rules apply. We need to reinterpret these rules to define how ``extra_items`` interacts with @@ -594,7 +594,7 @@ are assignable to ``VT``. For the purpose of this rule, a TypedDict that does not have ``extra_items=`` or ``closed=`` set is considered to have an item with a value of type ``object``. This extends the current assignability rule from the `typing spec -`__. +`__. For example:: diff --git a/peps/pep-0729.rst b/peps/pep-0729.rst index 060121b7996..a26ba2687c7 100644 --- a/peps/pep-0729.rst +++ b/peps/pep-0729.rst @@ -367,7 +367,7 @@ documentation for normal usage. Therefore, a separate user-facing reference for the type system would be useful. Such an effort could expand the documentation on -`typing.readthedocs.io `_ and +`typing.python.org `_ and reuse material from the documentation sections of individual type checkers and the CPython documentation. diff --git a/peps/pep-0767.rst b/peps/pep-0767.rst index 507afc01ac0..c5204734b38 100644 --- a/peps/pep-0767.rst +++ b/peps/pep-0767.rst @@ -111,7 +111,7 @@ Those requirements are satisfiable at runtime by all of the following: * an object with a ``@property`` ``def name(self) -> T``, * an object with a custom descriptor, such as :func:`functools.cached_property`. -The current `typing spec `_ +The current `typing spec `_ allows creation of such protocol members using (abstract) properties:: class HasName(Protocol): @@ -554,11 +554,11 @@ following the footsteps of :pep:`705#how-to-teach-this`: a ``TypedDict`` as read-only. * Add a standalone entry for ``ReadOnly`` under the - `type qualifiers `_ section: + `type qualifiers `_ section: The ``ReadOnly`` type qualifier in class attribute annotations indicates that the attribute of the class may be read, but not reassigned or ``del``\ eted. - For usage in ``TypedDict``, see `ReadOnly `_. + For usage in ``TypedDict``, see `ReadOnly `_. Rejected Ideas @@ -611,7 +611,7 @@ read-only attributes in such methods. It is unclear whether the rules could be satisfyingly shaped in a way that is inclusive of those 3rd party hooks, while upkeeping the invariants associated with the read-only-ness of those attributes. -The Python type system has a long and detailed `specification `_ +The Python type system has a long and detailed `specification `_ regarding the behavior of ``__new__`` and ``__init__``. It is rather unfeasible to expect the same level of detail from 3rd party hooks. @@ -641,7 +641,7 @@ Footnotes `[Pyre] `_ .. [#final_mutability] - As noted above the second-to-last code example of https://typing.readthedocs.io/en/latest/spec/qualifiers.html#semantics-and-examples + As noted above the second-to-last code example of https://typing.python.org/en/latest/spec/qualifiers.html#semantics-and-examples Copyright