Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
25 lines (16 loc) · 538 Bytes

File metadata and controls

25 lines (16 loc) · 538 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from typing import List
from classes import typeclass
@typeclass
def example(instance) -> str:
"""Example protocol."""
@example.instance(list)
def _example_list(instance: List) -> str:
return ''.join(str(col_item) for col_item in instance)
@example.instance(int)
def _example_int(instance: int) -> str:
return 'a' * instance
def test_regular_type() -> None:
"""Ensures that types correctly work."""
assert example([1, 2, 3]) == '123'
assert example(['a', 'b', 'c']) == 'abc'
assert example(2) == 'aa'
Morty Proxy This is a proxified and sanitized view of the page, visit original site.