-
Fork this project if you haven't done so
-
Determine how difficult the challenge is. There are 4 levels: basic, intermediate, advanced, and extreme.
-
Create a new directory under
challenges/
. The new directory's name should follow the pattern[basic|intermediate|advanced|extreme]-name
.For example, say you want to add a new challenge about Protocols. Since this is an advanced topic, you may name the directory
advanced-protocol
. -
Put a
question.py
and asolution.py
in the new directory. Here's an example:""" TODO: foo should accept a dict argument, both keys and values are string. """ def foo(x): pass def should_pass(): foo({"foo": "bar"}) def should_fail(): foo({"foo": 1})
You want to include several things in
question.py
- Describe the challenge, make sure people understand what they need to accomplish (the
TODO:
part) - Add two functions
should_pass
andshould_fail
as test cases. The function names are mandatory. With correct code,should_pass
should pass type check, andshould_fail
should fail type check.
Using the above challenge as an example, the correct answer is
def foo(x: dict[str, str]): pass
.This will pass type check:
def foo(x: dict[str, str]): pass def should_pass(): foo({"foo": "bar"})
This will fail type check
def foo(x: dict[str, str]): pass def should_fail(): foo({"foo": 1})
And the
solution.py
shall look like the same asquestion.py
, except that it has a solution provided.""" TODO: foo should accept a dict argument, both keys and values are string. """ def foo(x: dict[str, str]): pass def should_pass(): foo({"foo": "bar"}) def should_fail(): foo({"foo": 1})
- Describe the challenge, make sure people understand what they need to accomplish (the
-
Test with
mypy
to make sure your new challenge works as expected. -
Create a Pull Request.