Skip to content

Commit d08459e

Browse files
committed
Migrate to Python 3.8 and suggest using TypeDict (#6)
1 parent 073a08d commit d08459e

3 files changed

Lines changed: 33 additions & 3 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: python
22
python:
3-
- "3.7.5"
3+
- "3.8.3"
44
# command to install dependencies
55
install:
66
- make deps

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.7
4+
PYTHON=python3.8
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: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# clean-code-python
22

33
[![Build Status](https://travis-ci.com/zedr/clean-code-python.svg?branch=master)](https://travis-ci.com/zedr/clean-code-python)
4-
[![](https://img.shields.io/badge/python-3.7+-blue.svg)](https://www.python.org/download/releases/3.7.5/)
4+
[![](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/download/releases/3.8.3/)
55

66
## Table of Contents
77
1. [Introduction](#introduction)
@@ -366,6 +366,36 @@ create_menu(
366366
)
367367
```
368368

369+
**Even fancier, Python3.8+ only**
370+
```python
371+
class MenuConfig(typing.TypedDict):
372+
"""A configuration for the Menu.
373+
374+
Attributes:
375+
title: The title of the Menu.
376+
body: The body of the Menu.
377+
button_text: The text for the button label.
378+
cancellable: Can it be cancelled?
379+
"""
380+
title: str
381+
body: str
382+
button_text: str
383+
cancellable: bool = False
384+
385+
386+
def create_menu(config: MenuConfig):
387+
title = config["title"]
388+
# ...
389+
390+
391+
create_menu(
392+
{
393+
'title' : "My delicious menu",
394+
'body' : "A description of the various items on the menu",
395+
'button_text' : "Order now!"
396+
}
397+
)
398+
```
369399
**[⬆ back to top](#table-of-contents)**
370400

371401
### Functions should do one thing

0 commit comments

Comments
 (0)