-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refine some challenges, support mutitple solutions in testing
- Loading branch information
Showing
11 changed files
with
69 additions
and
135 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
""" | ||
TODO: | ||
Create a descriptor and annotate the __get__ method. | ||
HINT: use typing.overload | ||
""" | ||
|
||
|
||
class Descriptor: | ||
def __get__(self, instance, owner): | ||
"""you don't need to implement this""" | ||
... | ||
|
||
|
||
## End of your code ## | ||
class TestClass: | ||
a = Descriptor() | ||
|
||
|
||
def descriptor_self(x: Descriptor) -> None: | ||
... | ||
|
||
|
||
def string_value(x: str) -> None: | ||
... | ||
|
||
|
||
descriptor_self(TestClass.a) | ||
string_value(TestClass().a) | ||
descriptor_self(TestClass().a) # expect-type-error | ||
string_value(TestClass.a) # expect-type-error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from typing import Callable, Concatenate, Any, assert_type | ||
|
||
|
||
class Fn[R, **P](): | ||
def __init__(self, f: Callable[P, R]) -> None: | ||
self.f = f | ||
|
||
def into_callable(self) -> Callable[Concatenate[Any, P], R]: | ||
... | ||
|
||
|
||
## End of your code ## | ||
@Fn | ||
def example(a: int, b: str, c: float, *, d: bool = False) -> None: | ||
return | ||
|
||
|
||
assert_type(example.f(1, "1", 1.0, d=False), None) | ||
|
||
a: Any = 11111111 | ||
b = example.into_callable()(a, 1, "1", 1.0, d=False) | ||
assert_type(b, None) | ||
|
||
example.into_callable()(1, "1", 1.0, d=False) # expect-type-error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters