File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -344,6 +344,15 @@ Module contents
344344 Other attributes may exist, but they are private and must not be
345345 inspected or relied on.
346346
347+ .. class :: InitVar
348+
349+ ``InitVar[T] `` type annotations describe variables that are :ref: `init-only
350+ <dataclasses-init-only-variables>`. Fields annotated with :class: `!InitVar `
351+ are considered pseudo-fields, and thus are neither returned by the
352+ :func: `fields ` function nor used in any way except adding them as
353+ parameters to :meth: `~object.__init__ ` and an optional
354+ :meth: `__post_init__ `.
355+
347356.. function :: fields(class_or_instance)
348357
349358 Returns a tuple of :class: `Field ` objects that define the fields for this
@@ -600,8 +609,8 @@ Init-only variables
600609
601610Another place where :func: `@dataclass <dataclass> ` inspects a type annotation is to
602611determine if a field is an init-only variable. It does this by seeing
603- if the type of a field is of type `` dataclasses. InitVar` `. If a field
604- is an `` InitVar ` `, it is considered a pseudo-field called an init-only
612+ if the type of a field is of type :class: ` InitVar `. If a field
613+ is an :class: ` InitVar `, it is considered a pseudo-field called an init-only
605614field. As it is not a true field, it is not returned by the
606615module-level :func: `fields ` function. Init-only fields are added as
607616parameters to the generated :meth: `~object.__init__ ` method, and are passed to
You can’t perform that action at this time.
0 commit comments