Skip to content

TypeAliasType.__value__ might raise NameError, should we test it? #107905

@sobolevn

Description

@sobolevn
>>> type Invalid = dict[X, Y]

>>> Invalid[str, int]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Only generic type aliases are subscriptable

>>> Invalid.__value__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 1, in Invalid
NameError: name 'X' is not defined

This seems correct to me.

However, this case is not covered right now with existing tests.

But, before adding a test case for this error (that in my opinion will be quite common among devs: when you forget to add [X, Y] to type alias definition), I want to double check this with @JelleZijlstra

Linked PRs

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions