@@ -6,7 +6,7 @@ A set of examples to learn optional static typing in Python.
6
6
7
7
- Install Python 3.9.4+.
8
8
- Install poetry - https://python-poetry.org/docs/#installation .
9
- - Clone the repository and change the directory to clone one.
9
+ - Clone the repository and change the directory to the cloned one.
10
10
- Install requirements like ` poetry install ` .
11
11
12
12
- If you want to use pip, ` pip install -r requirements.txt ` .
@@ -20,8 +20,42 @@ about Python hints. It starts with simple variable annotation and covers topics
20
20
21
21
### How to run?
22
22
23
+ - Display one koan file
24
+
25
+ ``` bash
26
+ $cat koans/py/100-easy-variable-wrong-type.py
27
+ # msg variable is wrongly annotated as int, annotate it as string
28
+ msg: int = " hello world!"
29
+
30
+ # salary is annotated as int, annotate as float
31
+ salary: int = 2345.67
32
+
33
+ # Set is_active as bool
34
+ is_active: int = True
35
+ ```
36
+
23
37
- Run one koan file
24
38
39
+ ``` bash
40
+ $poetry run python cli.py one koans/py/100-easy-variable-wrong-type.py
41
+ ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
42
+ Running Mypy on koan file koans/py/100-easy-variable-wrong-type.py
43
+ ────────────────────────────────── Mypy errors in koan file koans/py/100-easy-variable-wrong-type.py ───────────────────────────────────
44
+ koans/py/100-easy-variable-wrong-type.py:2: error: Incompatible types in assignment (expression has type " str" , variable has type " int" )
45
+ msg: int = " hello world!"
46
+ ^
47
+ koans/py/100-easy-variable-wrong-type.py:5: error: Incompatible types in assignment (expression has type " float" , variable has type
48
+ " int" )
49
+ salary: int = 2345.67
50
+ ^
51
+ Found 2 errors in 1 file (checked 1 source file)
52
+
53
+ ────────────────────────────────────────────────────────────────── End ──────────────────────────────────────────────────────────────────
54
+ ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
55
+ ```
56
+
57
+ - Run after fixing the errors(riddles) in the file.
58
+
25
59
``` bash
26
60
$poetry run python cli.py one koans/py/100-easy-variable-wrong-type.py
27
61
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
0 commit comments