Skip to content

Commit 6640e74

Browse files
author
Artem Innokentiev
committed
Typos fix
1 parent 6ef000d commit 6640e74

File tree

2 files changed

+35
-26
lines changed

2 files changed

+35
-26
lines changed

EN.md

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# Evrone Python Guidelines
1+
# Evrone Python Guidelines (EN)
2+
3+
![GitHub last commit](https://img.shields.io/github/last-commit/evrone/evrone-python-guidelines?logo=GitHub)
4+
![GitHub release (latest by date)](https://img.shields.io/github/v/release/evrone/evrone-python-guidelines)
5+
26

37
## Table of Contents
48
- [About the code](#about-the-code)
@@ -30,13 +34,13 @@
3034
### Basic principles
3135
- **Maintainability** (will you be able to understand your code in a year or two?)
3236
- **Simplicity** (between a complex and a simple solution, you should choose the simple one)
33-
- **Plainness** (when a new programmer joins, how clear it will be to them why this code is written in this way?)
37+
- **Plainness** (when a new programmer joins, how clear it will be to them **why** this code is written in this way?)
3438

3539

3640
### Atomicity of operations
3741
**1 action ~ 1 line**
3842

39-
Try to do atomic operations in your code — there should be exactly one operation on each line.
43+
Try to do atomic operations in your code — there should be exactly **one** operation on each line.
4044

4145
Bad ❌:
4246
```python
@@ -135,15 +139,18 @@ def register_model(self, app_label, model):
135139
self.clear_cache()
136140
```
137141

138-
**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.
139144

140145

141146
### Sizes of methods, functions, and modules
142147

143-
The size limit for a method or function is 50 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 is 50 lines.
149+
Reaching the size limit indicates that the function (method) is doing too much — so decompose the actions inside the function (method).
144150

145151

146-
The module size limit is 300 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 is 300 lines.
153+
Reaching the size limit indicates that the module has received too much logic — so decompose the module into several ones.
147154

148155
The line length is 100 characters.
149156

@@ -164,7 +171,8 @@ Good ✅:
164171
from some.absolute.path import foo, bar
165172
```
166173

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`
168176

169177

170178
### Files `__init__.py`
@@ -176,7 +184,9 @@ Only write imports in `__init__.py` files.
176184

177185
### Docstrings
178186
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.
180190

181191

182192
## About Pull Requests
@@ -197,6 +207,7 @@ Refactoring is best done in a separate Pull Request.
197207

198208
### Pull Request Size
199209
The resulting PR diff should not exceed +/- 600 changed lines.
210+
200211
Bad ❌:
201212

202213
![bad](https://user-images.githubusercontent.com/8825727/113953748-6fc7ba80-9853-11eb-9673-827995e54f73.png)
@@ -211,7 +222,9 @@ Good ✅:
211222
Diff 222 + 111 = 333
212223
```
213224

214-
**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.
215228

216229

217230
## About tooling
@@ -234,7 +247,7 @@ python_files = tests.py test_*.py *_tests.py
234247
Black - PEP8 code auto-formatter
235248

236249
Recommended config in `pyproject.toml`:
237-
```
250+
```toml
238251
[tool.black]
239252
line-length = 100
240253
target-version = ['py38']
@@ -255,11 +268,12 @@ exclude = '''
255268
'''
256269
```
257270

271+
258272
### Imports formatting (isort)
259273
[isort](https://pycqa.github.io/isort/) - import block auto-formatter
260274

261275
Recommended config in `pyproject.toml`:
262-
```
276+
```toml
263277
[tool.isort]
264278
line_length = 100
265279
sections = ["FUTURE", "STDLIB", "DJANGO", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
@@ -270,6 +284,7 @@ src_paths = "app"
270284
lines_after_imports = 2
271285
```
272286

287+
273288
### Linter (flake8)
274289
[flake8](https://flake8.pycqa.org/en/latest/) - PEP8 conformance validator
275290

@@ -284,11 +299,12 @@ per-file-ignores =
284299
**/tests/**: S101
285300
```
286301

302+
287303
### Type checker (mypy)
288304
[mypy](http://mypy.readthedocs.io) - checker for static typing
289305

290306
Recommended config `mypy.ini`:
291-
```
307+
```ini
292308
[mypy]
293309
ignore_missing_imports = True
294310
allow_untyped_globals = True
@@ -297,6 +313,7 @@ allow_untyped_globals = True
297313
ignore_errors = True
298314
```
299315

316+
300317
### Pre-commit hooks (pre-commit)
301318

302319
[pre-commit](https://pre-commit.com) - framework for managing `pre-commit` hooks
@@ -333,7 +350,8 @@ repos:
333350
## Other
334351

335352
### REST API Documentation
336-
The recommended documentation format is [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 format is [OpenAPI](https://www.openapis.org).
354+
The schema for OpenAPI should be generated “on the fly” to provide API clients with fresh changes.
337355

338356
**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.
339357

RU.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Evrone Python Guidelines
1+
# Evrone Python Guidelines (RU)
22

33
![GitHub last commit](https://img.shields.io/github/last-commit/evrone/evrone-python-guidelines?logo=GitHub)
44
![GitHub release (latest by date)](https://img.shields.io/github/v/release/evrone/evrone-python-guidelines)
@@ -167,13 +167,12 @@ from . import foo, bar
167167

168168
Хорошо ✅:
169169
```python
170-
171170
# spam.py
172171
from some.absolute.path import foo, bar
173172
```
174173

175-
**Почему?** Потому что абсолютный импорт явно определяет локацию (путь) модуля, который импортируется. При релативном
176-
импорте всегда нужно помнить путь и вычислять в уме локацию модулей `foo.py`, `bar.py` относительно `spam.py`
174+
**Почему?** Потому что абсолютный импорт явно определяет локацию (путь) модуля, который импортируется.
175+
При релативном импорте всегда нужно помнить путь и вычислять в уме локацию модулей `foo.py`, `bar.py` относительно `spam.py`
177176

178177

179178
### Файлы `__init__.py`
@@ -238,11 +237,9 @@ from some.absolute.path import foo, bar
238237
[pytest]
239238
DJANGO_SETTINGS_MODULE = settings.local
240239
python_files = tests.py test_*.py *_tests.py
241-
242240
```
243241

244242
### Пакетный менеджер (poetry)
245-
246243
[poetry](https://python-poetry.org) - менеджер зависимостей и сборщик пакетов
247244

248245

@@ -251,7 +248,6 @@ python_files = tests.py test_*.py *_tests.py
251248

252249
Рекомендуемый конфиг в `pyproject.toml`:
253250
```toml
254-
255251
[tool.black]
256252
line-length = 100
257253
target-version = ['py38']
@@ -270,7 +266,6 @@ exclude = '''
270266
|dist
271267
)
272268
'''
273-
274269
```
275270

276271

@@ -279,7 +274,6 @@ exclude = '''
279274

280275
Рекомендуемый конфиг в `pyproject.toml`:
281276
```toml
282-
283277
[tool.isort]
284278
line_length = 100
285279
sections = ["FUTURE", "STDLIB", "DJANGO", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
@@ -288,7 +282,6 @@ known_django = "django"
288282
profile = "django"
289283
src_paths = "app"
290284
lines_after_imports = 2
291-
292285
```
293286

294287

@@ -308,19 +301,16 @@ per-file-ignores =
308301

309302

310303
### Тайп-чекер (mypy)
311-
312304
[mypy](http://mypy.readthedocs.io) - чекер для статической типизации
313305

314306
Рекомендуемый конфиг `mypy.ini`:
315-
316307
```ini
317308
[mypy]
318309
ignore_missing_imports = True
319310
allow_untyped_globals = True
320311

321312
[mypy-*.migrations.*]
322313
ignore_errors = True
323-
324314
```
325315

326316

@@ -365,5 +355,6 @@ repos:
365355

366356
**Почему?** Потому что это один из распространенных форматов для документирования REST API, который вышел из Swagger. Данный формат документации поддерживается большим количеством клиентов (Swagger, Postman, Insomnia Designer и многие другие). Также, рукописная документация имеет свойство быстро устаревать, а документация, которая генерируется напрямую из кода позволяет не думать о постоянном обновлении документации.
367357

358+
368359
## Спонсор
369360
[<img src="https://evrone.com/logo/evrone-sponsored-logo.png" width=300>](https://evrone.com/?utm_source=github.com&utm_campaign=evrone-python-codestyle)

0 commit comments

Comments
 (0)