Skip to content

Commit 4611fc5

Browse files
committed
Requires adding solution.py
1 parent e49640b commit 4611fc5

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ flask --app app run --debug
3030

3131
You're more than welcome to contribute new challenges!
3232

33-
All challenges live under the [`challenges/`](https://github.com/laike9m/Python-Type-Challenges/tree/main/challenges) directory, and it's pretty easy to add a new one: **you only need to create a new folder, add a `question.py`, and that's it**. See [here](docs/Contribute.md) for a detailed guidance.
33+
All challenges live under the [`challenges/`](https://github.com/laike9m/Python-Type-Challenges/tree/main/challenges) directory, and it's pretty easy to add a new one: **you only need to create a new folder, add a `question.py` and a `solution.py`, and that's it**. See [here](docs/Contribute.md) for a detailed guidance.
3434

3535
## Got Questions?
3636

docs/Contribute.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
For example, say you want to add a new challenge about [Protocols](https://mypy.readthedocs.io/en/stable/protocols.html). Since this is an advanced topic, you may name the directory `advanced-protocol`.
1010

11-
4. Put a `question.py` in the new directory. Here's an example:
11+
4. Put a `question.py` and a `solution.py` in the new directory. Here's an example:
1212
```python
1313
"""
1414
TODO:
@@ -53,6 +53,24 @@
5353
foo({"foo": 1})
5454
```
5555

56+
And the `solution.py` shall look like the same as `question.py`, except that it has a solution provided.
57+
58+
```python
59+
"""
60+
TODO:
61+
62+
foo should accept a dict argument, both keys and values are string.
63+
"""
64+
65+
def foo(x: dict[str, str]): pass
66+
67+
def should_pass():
68+
foo({"foo": "bar"})
69+
70+
def should_fail():
71+
foo({"foo": 1})
72+
```
73+
5674
5. Test with [`mypy`](https://mypy.readthedocs.io/) to make sure your new challenge works as expected.
5775

5876
6. Create a Pull Request.

0 commit comments

Comments
 (0)