File: autonamedtuple_demo_pep563.py

package info (click to toggle)
sphinx-toolbox 3.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,924 kB
  • sloc: python: 11,636; sh: 26; javascript: 25; makefile: 16
file content (29 lines) | stat: -rw-r--r-- 567 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
# Examples from
# https://docs.python.org/3/library/typing.html#typing.NamedTuple
# https://www.python.org/dev/peps/pep-0589/#totality
# https://github.com/python/typing/pull/700

# stdlib
import sys

__all__ = ("Animal", )

if sys.version_info < (3, 7):

	# stdlib
	from typing import Callable, NamedTuple

	class Animal(NamedTuple):
		"""
		An animal.

		:param name: The name of the animal.
		:param voice: The animal's voice.
		"""

		name: str
		voice: "Callable[[], str]"

else:
	# this package
	from tests.test_output._autonamedtuple_demo_pep563 import Animal