From 26830719e0843197eed5fd433b816da48c634be5 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 7 Apr 2024 07:53:22 -0400 Subject: [PATCH] dataclasses docs: add some link anchors These would be useful to link to in the typing spec. --- Doc/library/dataclasses.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Doc/library/dataclasses.rst b/Doc/library/dataclasses.rst index 61b2263339da71..617fb8050cef8a 100644 --- a/Doc/library/dataclasses.rst +++ b/Doc/library/dataclasses.rst @@ -556,6 +556,8 @@ See the section below on init-only variables for ways to pass parameters to :meth:`!__post_init__`. Also see the warning about how :func:`replace` handles ``init=False`` fields. +.. _dataclasses-class-variables: + Class variables --------------- @@ -567,6 +569,8 @@ from consideration as a field and is ignored by the dataclass mechanisms. Such ``ClassVar`` pseudo-fields are not returned by the module-level :func:`fields` function. +.. _dataclasses-init-only: + Init-only variables ------------------- @@ -598,6 +602,8 @@ value is not provided when creating the class:: In this case, :func:`fields` will return :class:`Field` objects for ``i`` and ``j``, but not for ``database``. +.. _dataclasses-frozen: + Frozen instances ---------------- @@ -611,6 +617,8 @@ There is a tiny performance penalty when using ``frozen=True``: :meth:`~object.__init__` cannot use simple assignment to initialize fields, and must use :meth:`!__setattr__`. +.. _dataclasses-inheritance: + Inheritance -----------