You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Why?** In addition to improving readability, The Zen of Python teaches us how to write idiomatic Python code. One of the statements claims that "sparse is better than dense." Compressed code is harder to read than sparse code.
142
+
**Why?** In addition to improving readability, [The Zen of Python](https://www.python.org/dev/peps/pep-0020/) teaches us how to write idiomatic Python code.
143
+
One of the statements claims that "sparse is better than dense." Compressed code is harder to read than sparse code.
139
144
140
145
141
146
### Sizes of methods, functions, and modules
142
147
143
-
The size limit for a method or function is50 lines. Reaching the size limit indicates that the function (method) is doing too much — so decompose the actions inside the function (method).
148
+
The size limit for a method or function is50 lines.
149
+
Reaching the size limit indicates that the function (method) is doing too much — so decompose the actions inside the function (method).
144
150
145
151
146
-
The module size limit is300 lines. Reaching the size limit indicates that the module has received too much logic — so decompose the module into several ones.
152
+
The module size limit is300 lines.
153
+
Reaching the size limit indicates that the module has received too much logic — so decompose the module into several ones.
147
154
148
155
The line length is100 characters.
149
156
@@ -164,7 +171,8 @@ Good ✅:
164
171
from some.absolute.path import foo, bar
165
172
```
166
173
167
-
**Why?** Because absolute import explicitly defines the location (path) of the module that is being imported. With relative imports, you always need to remember the path and calculate in your mind the location of the modules `foo.py`, `bar.py` relative to `spam.py`
174
+
**Why?** Because absolute import explicitly defines the location (path) of the module that is being imported.
175
+
With relative imports, you always need to remember the path and calculate in your mind the location of the modules `foo.py`, `bar.py` relative to `spam.py`
168
176
169
177
170
178
### Files `__init__.py`
@@ -176,7 +184,9 @@ Only write imports in `__init__.py` files.
176
184
177
185
### Docstrings
178
186
We recommend adding docstrings to functions, methods, and classes.
179
-
**Why?** Because the programmer who sees your code for the first time will be able to quickly understand what is happening in it. Code is read much more than it is written.
187
+
188
+
**Why?** Because the programmer who sees your code for the first time will be able to quickly understand what is happening in it.
189
+
Code is read much more than it is written.
180
190
181
191
182
192
## About Pull Requests
@@ -197,6 +207,7 @@ Refactoring is best done in a separate Pull Request.
197
207
198
208
### Pull Request Size
199
209
The resulting PR diff should not exceed +/-600 changed lines.
**Why?** Because the more PR involves, the more uncontrollable it becomes, and the merge is made "with eyes closed and ears shut." Also, most reviewers will find it difficult to accept a large volume of changes at once.
225
+
226
+
**Why?** Because the more PR involves, the more uncontrollable it becomes, and the merge is made "with eyes closed and ears shut."
227
+
Also, most reviewers will find it difficult to accept a large volume of changes at once.
[mypy](http://mypy.readthedocs.io) - checker for static typing
289
305
290
306
Recommended config `mypy.ini`:
291
-
```
307
+
```ini
292
308
[mypy]
293
309
ignore_missing_imports=True
294
310
allow_untyped_globals=True
@@ -297,6 +313,7 @@ allow_untyped_globals = True
297
313
ignore_errors=True
298
314
```
299
315
316
+
300
317
### Pre-commit hooks (pre-commit)
301
318
302
319
[pre-commit](https://pre-commit.com) - framework for managing `pre-commit` hooks
@@ -333,7 +350,8 @@ repos:
333
350
## Other
334
351
335
352
### REST API Documentation
336
-
The recommended documentation formatis [OpenAPI](https://www.openapis.org). The schema for OpenAPI should be generated “on the fly” to provide API clients with fresh changes.
353
+
The recommended documentation formatis [OpenAPI](https://www.openapis.org).
354
+
The schema for OpenAPI should be generated “on the fly” to provide API clients with fresh changes.
337
355
338
356
**Why?** Because it's one of the common formats for documenting REST APIs that come out of Swagger. This documentation format is supported by a large number of clients (Swagger, Postman, Insomnia Designer, and many others). Also, handwritten documentation tends to quickly become outdated, and documentation that is generated directly from the code allows you to avoid constantly thinking about updating the documentation.
[mypy](http://mypy.readthedocs.io) - чекер для статической типизации
313
305
314
306
Рекомендуемый конфиг `mypy.ini`:
315
-
316
307
```ini
317
308
[mypy]
318
309
ignore_missing_imports=True
319
310
allow_untyped_globals=True
320
311
321
312
[mypy-*.migrations.*]
322
313
ignore_errors=True
323
-
324
314
```
325
315
326
316
@@ -365,5 +355,6 @@ repos:
365
355
366
356
**Почему?** Потому что это один из распространенных форматов для документирования RESTAPI, который вышел из Swagger. Данный формат документации поддерживается большим количеством клиентов (Swagger, Postman, Insomnia Designer и многие другие). Также, рукописная документация имеет свойство быстро устаревать, а документация, которая генерируется напрямую из кода позволяет не думать о постоянном обновлении документации.
0 commit comments