@@ -40,10 +40,10 @@ To report a bug or request an enhancement:
40
40
tracker for that library
41
41
42
42
To discuss a new type system feature:
43
+
43
44
- discuss at
[ typing-sig mailing list
] ( https://mail.python.org/archives/list/[email protected] / )
44
45
- there is also some historical discussion [ here] ( https://github.com/python/typing/issues )
45
46
46
-
47
47
What is mypy?
48
48
-------------
49
49
@@ -82,6 +82,7 @@ See [the documentation](https://mypy.readthedocs.io/en/stable/index.html) for
82
82
more examples and information.
83
83
84
84
In particular, see:
85
+
85
86
- [ type hints cheat sheet] ( https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html )
86
87
- [ getting started] ( https://mypy.readthedocs.io/en/stable/getting_started.html )
87
88
- [ list of error codes] ( https://mypy.readthedocs.io/en/stable/error_code_list.html )
@@ -91,67 +92,75 @@ Quick start
91
92
92
93
Mypy can be installed using pip:
93
94
94
- python3 -m pip install -U mypy
95
+ ``` bash
96
+ python3 -m pip install -U mypy
97
+ ```
95
98
96
99
If you want to run the latest version of the code, you can install from the
97
100
repo directly:
98
101
99
- python3 -m pip install -U git+https://github.com/python/mypy.git
100
- # or if you don't have 'git' installed
101
- python3 -m pip install -U https://github.com/python/mypy/zipball/master
102
+ ``` bash
103
+ python3 -m pip install -U git+https://github.com/python/mypy.git
104
+ # or if you don't have 'git' installed
105
+ python3 -m pip install -U https://github.com/python/mypy/zipball/master
106
+ ```
102
107
103
108
Now you can type-check the [ statically typed parts] of a program like this:
104
109
105
- mypy PROGRAM
110
+ ``` bash
111
+ mypy PROGRAM
112
+ ```
106
113
107
114
You can always use the Python interpreter to run your statically typed
108
115
programs, even if mypy reports type errors:
109
116
110
- python3 PROGRAM
117
+ ``` bash
118
+ python3 PROGRAM
119
+ ```
111
120
112
121
You can also try mypy in an [ online playground] ( https://mypy-play.net/ ) (developed by
113
122
Yusuke Miyazaki). If you are working with large code bases, you can run mypy in
114
123
[ daemon mode] , that will give much faster (often sub-second) incremental updates:
115
124
116
- dmypy run -- PROGRAM
125
+ ``` bash
126
+ dmypy run -- PROGRAM
127
+ ```
117
128
118
129
[ statically typed parts ] : https://mypy.readthedocs.io/en/latest/getting_started.html#function-signatures-and-dynamic-vs-static-typing
119
130
[ daemon mode ] : https://mypy.readthedocs.io/en/stable/mypy_daemon.html
120
131
121
-
122
132
Integrations
123
133
------------
124
134
125
135
Mypy can be integrated into popular IDEs:
126
136
127
- * Vim:
128
- * Using [ Syntastic] ( https://github.com/vim-syntastic/syntastic ) : in ` ~/.vimrc ` add
137
+ - Vim:
138
+ - Using [ Syntastic] ( https://github.com/vim-syntastic/syntastic ) : in ` ~/.vimrc ` add
129
139
` let g:syntastic_python_checkers=['mypy'] `
130
- * Using [ ALE] ( https://github.com/dense-analysis/ale ) : should be enabled by default when ` mypy ` is installed,
140
+ - Using [ ALE] ( https://github.com/dense-analysis/ale ) : should be enabled by default when ` mypy ` is installed,
131
141
or can be explicitly enabled by adding ` let b:ale_linters = ['mypy'] ` in ` ~/vim/ftplugin/python.vim `
132
- * Emacs: using [ Flycheck] ( https://github.com/flycheck/ )
133
- * Sublime Text: [ SublimeLinter-contrib-mypy] ( https://github.com/fredcallaway/SublimeLinter-contrib-mypy )
134
- * Atom: [ linter-mypy] ( https://atom.io/packages/linter-mypy )
135
- * PyCharm: [ mypy plugin] ( https://github.com/dropbox/mypy-PyCharm-plugin ) (PyCharm integrates
142
+ - Emacs: using [ Flycheck] ( https://github.com/flycheck/ )
143
+ - Sublime Text: [ SublimeLinter-contrib-mypy] ( https://github.com/fredcallaway/SublimeLinter-contrib-mypy )
144
+ - Atom: [ linter-mypy] ( https://atom.io/packages/linter-mypy )
145
+ - PyCharm: [ mypy plugin] ( https://github.com/dropbox/mypy-PyCharm-plugin ) (PyCharm integrates
136
146
[ its own implementation] ( https://www.jetbrains.com/help/pycharm/type-hinting-in-product.html ) of [ PEP 484] ( https://peps.python.org/pep-0484/ ) )
137
- * VS Code: provides [ basic integration] ( https://code.visualstudio.com/docs/python/linting#_mypy ) with mypy.
138
- * pre-commit: use [ pre-commit mirrors-mypy] ( https://github.com/pre-commit/mirrors-mypy ) .
147
+ - VS Code: provides [ basic integration] ( https://code.visualstudio.com/docs/python/linting#_mypy ) with mypy.
148
+ - pre-commit: use [ pre-commit mirrors-mypy] ( https://github.com/pre-commit/mirrors-mypy ) .
139
149
140
150
Web site and documentation
141
151
--------------------------
142
152
143
153
Additional information is available at the web site:
144
154
145
- https://www.mypy-lang.org/
155
+ < https://www.mypy-lang.org/ >
146
156
147
157
Jump straight to the documentation:
148
158
149
- https://mypy.readthedocs.io/
159
+ < https://mypy.readthedocs.io/ >
150
160
151
161
Follow along our changelog at:
152
162
153
- https://mypy-lang.blogspot.com/
154
-
163
+ < https://mypy-lang.blogspot.com/ >
155
164
156
165
Contributing
157
166
------------
@@ -164,7 +173,6 @@ To get started with developing mypy, see [CONTRIBUTING.md](CONTRIBUTING.md).
164
173
165
174
If you need help getting started, don't hesitate to ask on [ gitter] ( https://gitter.im/python/typing ) .
166
175
167
-
168
176
Mypyc and compiled version of mypy
169
177
----------------------------------
170
178
@@ -174,10 +182,12 @@ mypy approximately 4 times faster than if interpreted!
174
182
175
183
To install an interpreted mypy instead, use:
176
184
177
- python3 -m pip install --no-binary mypy -U mypy
185
+ ``` bash
186
+ python3 -m pip install --no-binary mypy -U mypy
187
+ ```
178
188
179
189
To use a compiled version of a development
180
190
version of mypy, directly install a binary from
181
- https://github.com/mypyc/mypy_mypyc-wheels/releases/latest .
191
+ < https://github.com/mypyc/mypy_mypyc-wheels/releases/latest > .
182
192
183
- To contribute to the mypyc project, check out https://github.com/mypyc/mypyc
193
+ To contribute to the mypyc project, check out < https://github.com/mypyc/mypyc >
0 commit comments