Debian Codegraph @

docs/source/index.rst

raw
1 .. Mypy documentation master file, created by
2 sphinx-quickstart on Sun Sep 14 19:50:35 2014.
3 You can adapt this file completely to your liking, but it should at least
4 contain the root `toctree` directive.
5
6 Welcome to mypy documentation!
7 ==============================
8
9 Mypy is a static type checker for Python.
10
11 Type checkers help ensure that you're using variables and functions in your code
12 correctly. With mypy, add type hints (:pep:`484`)
13 to your Python programs, and mypy will warn you when you use those types
14 incorrectly.
15
16 Python is a dynamic language, so usually you'll only see errors in your code
17 when you attempt to run it. Mypy is a *static* checker, so it finds bugs
18 in your programs without even running them!
19
20 Here is a small example to whet your appetite:
21
22 .. code-block:: python
23
24 number = input("What is your favourite number?")
25 print("It is", number + 1) # error: Unsupported operand types for + ("str" and "int")
26
27 Adding type hints for mypy does not interfere with the way your program would
28 otherwise run. Think of type hints as similar to comments! You can always use
29 the Python interpreter to run your code, even if mypy reports errors.
30
31 Mypy is designed with gradual typing in mind. This means you can add type
32 hints to your code base slowly and that you can always fall back to dynamic
33 typing when static typing is not convenient.
34
35 Mypy has a powerful and easy-to-use type system, supporting features such as
36 type inference, generics, callable types, tuple types, union types,
37 structural subtyping and more. Using mypy will make your programs easier to
38 understand, debug, and maintain.
39
40 .. note::
41
42 Although mypy is production ready, there may be occasional changes
43 that break backward compatibility. The mypy development team tries to
44 minimize the impact of changes to user code. In case of a major breaking
45 change, mypy's major version will be bumped.
46
47 Contents
48 --------
49
50 .. toctree::
51 :maxdepth: 2
52 :caption: First steps
53
54 getting_started
55 cheat_sheet_py3
56 existing_code
57
58 .. _overview-type-system-reference:
59
60 .. toctree::
61 :maxdepth: 2
62 :caption: Type system reference
63
64 builtin_types
65 type_inference_and_annotations
66 kinds_of_types
67 class_basics
68 runtime_troubles
69 protocols
70 dynamic_typing
71 type_narrowing
72 duck_type_compatibility
73 stubs
74 generics
75 more_types
76 literal_types
77 typed_dict
78 final_attrs
79 metaclasses
80
81 .. toctree::
82 :maxdepth: 2
83 :caption: Configuring and running mypy
84
85 running_mypy
86 command_line
87 config_file
88 inline_config
89 mypy_daemon
90 installed_packages
91 extending_mypy
92 stubgen
93 stubtest
94
95 .. toctree::
96 :maxdepth: 2
97 :caption: Miscellaneous
98
99 common_issues
100 supported_python_features
101 error_codes
102 error_code_list
103 error_code_list2
104 additional_features
105 faq
106 changelog
107
108 .. toctree::
109 :hidden:
110 :caption: Project Links
111
112 GitHub <https://github.com/python/mypy>
113 Website <https://mypy-lang.org/>
114
115 Indices and tables
116 ==================
117
118 * :ref:`genindex`
119 * :ref:`search`