Skip to content

Commit 427808c

Browse files
committed
Make extreme-variance more strict, add hints. Fixed laike9m#89
1 parent 35487f7 commit 427808c

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

challenges/extreme-variance/hints.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Check out [Covariance and Contravariance](https://peps.python.org/pep-0483/#covariance-and-contravariance)
2+
- A bytes object behaves like an immutable sequences of integers

challenges/extreme-variance/question.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ def g(a):
2222
g(l2)
2323

2424
f(1) # expect-type-error
25-
f("1") # expect-type-error
25+
f("abc") # expect-type-error
26+
g("abc")
27+
g(b"abc")
28+
g([1, "2"])
29+
g((1, "2", 3))
2630
g(1) # expect-type-error
27-
g("1")
31+
g({1}) # expect-type-error

challenges/extreme-variance/solution.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ def g(a: Sequence[int | str]):
2424
g(l2)
2525

2626
f(1) # expect-type-error
27-
f("1") # expect-type-error
27+
f("abc") # expect-type-error
28+
g("abc")
29+
g(b"abc")
30+
g([1, "2"])
31+
g((1, "2", 3))
2832
g(1) # expect-type-error
29-
g("1")
33+
g({1}) # expect-type-error

0 commit comments

Comments
 (0)