Skip to content

Commit 638707c

Browse files
Merge branch 'master' into feature/link-pt-br
2 parents 3f5f2a9 + e16c09e commit 638707c

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

CONTRIBUTORS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ Miguel Gonzalez <https://github.com/migonzalvar>
99
Anvar <https://github.com/arpanetus>
1010
Martin Pavlásek <https://github.com/mpavlase>
1111
Shahrukh Khan <https://github.com/shahrukhx01>
12+
Aaron Law <https://github.com/AaronLaw>
13+
Fredson Chaves <https://github.com/fredsonchaves07>

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.PHONY: deps clean tests
22

33
ENV=.env
4-
PYTHON=python3.8
4+
PYTHON=python3
55
PYTHON_VERSION=$(shell ${PYTHON} -V | cut -d " " -f 2 | cut -c1-3)
66
SITE_PACKAGES=${ENV}/lib/python${PYTHON_VERSION}/site-packages
77
IN_ENV=source ${ENV}/bin/activate;

README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Targets Python3.7+
3636
### Use meaningful and pronounceable variable names
3737

3838
**Bad:**
39+
3940
```python
4041
import datetime
4142

@@ -44,6 +45,7 @@ ymdstr = datetime.date.today().strftime("%y-%m-%d")
4445
```
4546

4647
**Good**:
48+
4749
```python
4850
import datetime
4951

@@ -56,6 +58,7 @@ current_date: str = datetime.date.today().strftime("%y-%m-%d")
5658

5759
**Bad:**
5860
Here we use three different names for the same underlying entity:
61+
5962
```python
6063
def get_user_info(): pass
6164
def get_client_data(): pass
@@ -64,6 +67,7 @@ def get_customer_record(): pass
6467

6568
**Good**:
6669
If the entity is the same, you should be consistent in referring to it in your functions:
70+
6771
```python
6872
def get_user_info(): pass
6973
def get_user_data(): pass
@@ -102,6 +106,7 @@ understanding our program, we hurt our readers.
102106
Make your names searchable.
103107

104108
**Bad:**
109+
105110
```python
106111
import time
107112

@@ -111,6 +116,7 @@ time.sleep(86400)
111116
```
112117

113118
**Good**:
119+
114120
```python
115121
import time
116122

@@ -123,6 +129,7 @@ time.sleep(SECONDS_IN_A_DAY)
123129

124130
### Use explanatory variables
125131
**Bad:**
132+
126133
```python
127134
import re
128135

@@ -155,6 +162,7 @@ if matches:
155162
**Good**:
156163

157164
Decrease dependence on regex by naming subpatterns.
165+
158166
```python
159167
import re
160168

@@ -173,6 +181,7 @@ Don’t force the reader of your code to translate what the variable means.
173181
Explicit is better than implicit.
174182

175183
**Bad:**
184+
176185
```python
177186
seq = ("Austin", "New York", "San Francisco")
178187

@@ -185,6 +194,7 @@ for item in seq:
185194
```
186195

187196
**Good**:
197+
188198
```python
189199
locations = ("Austin", "New York", "San Francisco")
190200

@@ -266,12 +276,14 @@ arguments then your function is trying to do too much. In cases where it's not,
266276
of the time a higher-level object will suffice as an argument.
267277

268278
**Bad:**
279+
269280
```python
270281
def create_menu(title, body, button_text, cancellable):
271282
pass
272283
```
273284

274285
**Java-esque**:
286+
275287
```python
276288
class Menu:
277289
def __init__(self, config: dict):
@@ -290,6 +302,7 @@ menu = Menu(
290302
```
291303

292304
**Also good**
305+
293306
```python
294307
from typing import Text
295308

@@ -326,6 +339,7 @@ create_menu(config)
326339
```
327340

328341
**Fancy**
342+
329343
```python
330344
from typing import NamedTuple
331345

@@ -360,6 +374,7 @@ create_menu(
360374
```
361375

362376
**Even fancier**
377+
363378
```python
364379
from typing import Text
365380
from dataclasses import astuple, dataclass
@@ -395,6 +410,7 @@ create_menu(
395410
```
396411

397412
**Even fancier, Python3.8+ only**
413+
398414
```python
399415
from typing import TypedDict, Text
400416

@@ -439,6 +455,7 @@ cleaner. If you take nothing else away from this guide other than this, you'll b
439455
of many developers.
440456

441457
**Bad:**
458+
442459
```python
443460
from typing import List
444461

@@ -460,6 +477,7 @@ def email_clients(clients: List[Client]) -> None:
460477
```
461478

462479
**Good**:
480+
463481
```python
464482
from typing import List
465483

@@ -488,6 +506,7 @@ def email_clients(clients: List[Client]) -> None:
488506
Do you see an opportunity for using generators now?
489507

490508
**Even better**
509+
491510
```python
492511
from typing import Generator, Iterator
493512

@@ -695,6 +714,7 @@ print(fullname) # ["Ryan", "McDermott"]
695714
```
696715

697716
**Good:**
717+
698718
```python
699719
from typing import List, AnyStr
700720

@@ -709,6 +729,7 @@ print(name, surname) # => Ryan McDermott
709729
```
710730

711731
**Also good**
732+
712733
```python
713734
from typing import Text
714735
from dataclasses import dataclass
@@ -891,9 +912,9 @@ company_managers_list = get_employee_list(employees=company_managers)
891912

892913
**[⬆ back to top](#table-of-contents)**
893914

894-
## **Translation**
915+
## **Translations**
895916

896-
This is also available in other languages:
917+
This document is also available in other languages:
897918

898919
- ![br](https://raw.githubusercontent.com/gosquared/flags/master/flags/flags/shiny/24/Brazil.png) **Brazilian Portuguese**: [fredsonchaves07/clean-code-python](https://github.com/fredsonchaves07/clean-code-python)
899920

0 commit comments

Comments
 (0)