8000 Add PEP 613 TypeAlias to typing_extensions by east825 · Pull Request #732 · python/typing · GitHub
[go: up one dir, main page]

Skip to content

Add PEP 613 TypeAlias to typing_extensions #732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add positive tests on canonical usage of TypeAlias
  • Loading branch information
east825 committed Jun 15, 2020
commit 37eb9da08f7ede09e6dd71bb839e9788ae623adb
3 changes: 3 additions & 0 deletions typing_extensions/src_py2/test_typing_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,9 @@ def test_annotated_in_other_types(self):


class TypeAliasTests(BaseTestCase):
def test_canonical_usage(self):
Alias = Employee # type: TypeAlias

def test_cannot_instantiate(self):
with self.assertRaises(TypeError):
TypeAlias()
Expand Down
8 changes: 8 additions & 0 deletions typing_extensions/src_py3/test_typing_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1824,6 +1824,14 @@ def __iand__(self, other: Const["MySet[T]"]) -> "MySet[T]":


class TypeAliasTests(BaseTestCase):
@skipUnless(PY36, 'Python 3.6 required')
def test_canonical_usage_with_variable_annotation(self):
ns = {}
exec('Alias: TypeAlias = Employee', globals(), ns)

def test_canonical_usage_with_type_comment(self):
Alias = Employee # type: TypeAlias

def test_cannot_instantiate(self):
with self.assertRaises(TypeError):
TypeAlias()
Expand Down
0