@@ -124,8 +124,8 @@ explains how to download and install mypy.
124
124
125
125
.. _library-stubs :
126
126
127
- Library stubs
128
- *************
127
+ Typeshed
128
+ ********
129
129
130
130
In order to type check code that uses library modules such as those
131
131
included in the Python standard library, you need to have library
@@ -141,8 +141,9 @@ For example, consider this code:
141
141
142
142
Without a library stub, the type checker has no way of inferring the
143
143
type of ``x `` and checking that the argument to ``chr `` has a valid
144
- type. Mypy comes with a library stub for Python builtins that contains
145
- a definition like this for ``chr ``:
144
+ type. Mypy contains the `typeshed http://github.com/python/typeshed `_ project,
145
+ which contains library stubs for Python builtins that contains a definition
146
+ like this for ``chr ``:
146
147
147
148
.. code-block :: python
148
149
@@ -167,9 +168,13 @@ for module ``csv``, and use a subdirectory with ``__init__.pyi`` for packages.
167
168
If there is both a ``.py `` and a ``.pyi `` file for a module, the ``.pyi `` file
168
169
takes precedence. This way you can easily add annotations for a module even if
169
170
you don't want to modify the source code. This can be useful, for example, if you
170
- use 3rd party open source libraries in your program. You can also override the stubs
171
- mypy uses for standard libary modules, in case you need to make local
172
- modifications.
171
+ use 3rd party open source libraries in your program.
172
+
173
+ You can also override the stubs mypy uses for standard libary modules, in case
174
+ you need to make local modifications. (Note that if you want to submit your
175
+ changes, please submit a pull request to `typeshed http://github.com/python/typeshed `_
176
+ first, and then update the submodule in mypy using a commit that only touches
177
+ the typeshed submodule and nothing else)
173
178
174
179
That's it! Now you can access the module in mypy programs and type check
175
180
code that uses the library. If you write a stub for a library module,
0 commit comments