mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Improve repr for TypeAliasForwardRef
This commit is contained in:
@@ -547,7 +547,7 @@ class TypeAliasForwardRef:
|
||||
return hash(self.name)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return self.name
|
||||
return f'{self.__class__.__name__}({self.name!r})'
|
||||
|
||||
|
||||
class TypeAliasModule:
|
||||
|
||||
@@ -94,11 +94,11 @@ def _decorator(f):
|
||||
def test_TypeAliasForwardRef():
|
||||
alias = TypeAliasForwardRef('example')
|
||||
sig_str = stringify_annotation(alias, 'fully-qualified-except-typing')
|
||||
assert sig_str == 'example'
|
||||
assert sig_str == "TypeAliasForwardRef('example')"
|
||||
|
||||
alias = Optional[alias] # NoQA: UP007
|
||||
sig_str = stringify_annotation(alias, 'fully-qualified-except-typing')
|
||||
assert sig_str == 'example | None'
|
||||
assert sig_str == "TypeAliasForwardRef('example') | None"
|
||||
|
||||
|
||||
def test_TypeAliasNamespace():
|
||||
|
||||
Reference in New Issue
Block a user