File: misc_py312.py

package info (click to toggle)
python-pdoc 16.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,080 kB
  • sloc: python: 5,260; javascript: 1,156; makefile: 18; sh: 3
file content (37 lines) | stat: -rwxr-xr-x 822 bytes parent folder | download | duplicates (2)
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
# mypy: ignore-errors
# https://github.com/python/mypy/issues/16607
"""
Testing features that either are 3.12+ only or render slightly different on 3.12.
"""

from __future__ import annotations

import typing
from typing import NamedTuple

# Testing the new Python 3.12 `type` statement.
type MyType = int
"""A custom Python 3.12 type."""

foo: MyType
"""A custom type instance."""


type MyTypeWithoutDocstring = int

MyTypeClassic: typing.TypeAlias = int
"""A "classic" typing.TypeAlias."""

# Testing a typing.NamedTuple
# we do not care very much about collections.namedtuple,
# the typing version is superior for documentation and a drop-in replacement.


class NamedTupleExample(NamedTuple):
    """
    An example for a typing.NamedTuple.
    """

    name: str
    """Name of our example tuple."""
    id: int = 3