summaryrefslogtreecommitdiffstats
path: root/tests/roots/test-ext-autodoc/target/preserve_defaults_special_constructs.py
blob: 0fdb11ac8749a2f32717da6b41b46a09ed0c2a7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from __future__ import annotations

from collections import namedtuple
from dataclasses import dataclass, field
from typing import NamedTuple, TypedDict

#: docstring
SENTINEL = object()


#: docstring
ze_lambda = lambda z=SENTINEL: None


def foo(x, y, z=SENTINEL):
    """docstring"""


@dataclass
class DataClass:
    """docstring"""
    a: int
    b: object = SENTINEL
    c: list[int] = field(default_factory=lambda: [1, 2, 3])


@dataclass(init=False)
class DataClassNoInit:
    """docstring"""
    a: int
    b: object = SENTINEL
    c: list[int] = field(default_factory=lambda: [1, 2, 3])


class MyTypedDict(TypedDict):
    """docstring"""
    a: int
    b: object
    c: list[int]


class MyNamedTuple1(NamedTuple):
    """docstring"""
    a: int
    b: object = object()
    c: list[int] = [1, 2, 3]


class MyNamedTuple2(namedtuple('Base', ('a', 'b'), defaults=(0, SENTINEL))):
    """docstring"""