Debian Codegraph @

tests/roots/test-ext-autodoc/target/annotated.py

raw
1 # from __future__ import annotations
2
3 import dataclasses
4 import types
5 from typing import Annotated
6
7
8 @dataclasses.dataclass(frozen=True)
9 class FuncValidator:
10 func: types.FunctionType
11
12
13 @dataclasses.dataclass(frozen=True)
14 class MaxLen:
15 max_length: int
16 whitelisted_words: list[str]
17
18
19 def validate(value: str) -> str:
20 return value
21
22
23 #: Type alias for a validated string.
24 ValidatedString = Annotated[str, FuncValidator(validate)]
25
26
27 def hello(name: Annotated[str, 'attribute']) -> None:
28 """docstring"""
29 pass
30
31
32 class AnnotatedAttributes:
33 """docstring"""
34
35 #: Docstring about the ``name`` attribute.
36 name: Annotated[str, 'attribute']
37
38 #: Docstring about the ``max_len`` attribute.
39 max_len: list[Annotated[str, MaxLen(10, ['word_one', 'word_two'])]]
40
41 #: Docstring about the ``validated`` attribute.
42 validated: ValidatedString