mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-19 06:49:38 +08:00
Implement Final[...] in a way so it doesn't completely fail
This commit is contained in:
@@ -33,7 +33,8 @@ _TYPE_ALIAS_TYPES = {
|
|||||||
'DefaultDict': 'collections.defaultdict',
|
'DefaultDict': 'collections.defaultdict',
|
||||||
'Deque': 'collections.deque',
|
'Deque': 'collections.deque',
|
||||||
}
|
}
|
||||||
_PROXY_TYPES = 'Optional Union ClassVar Annotated'.split()
|
_PROXY_TYPES = ['Optional', 'Union', 'ClassVar', 'Annotated', 'Final']
|
||||||
|
_IGNORE_ANNOTATION_PARTS = ['ClassVar', 'Annotated', 'Final']
|
||||||
|
|
||||||
|
|
||||||
class TypingModuleName(NameWrapper):
|
class TypingModuleName(NameWrapper):
|
||||||
@@ -114,7 +115,7 @@ class ProxyWithGenerics(BaseTypingClassWithGenerics):
|
|||||||
elif string_name == 'Type':
|
elif string_name == 'Type':
|
||||||
# The type is actually already given in the index_value
|
# The type is actually already given in the index_value
|
||||||
return self._generics_manager[0]
|
return self._generics_manager[0]
|
||||||
elif string_name in ['ClassVar', 'Annotated']:
|
elif string_name in _IGNORE_ANNOTATION_PARTS:
|
||||||
# For now don't do anything here, ClassVars are always used.
|
# For now don't do anything here, ClassVars are always used.
|
||||||
return self._generics_manager[0].execute_annotation()
|
return self._generics_manager[0].execute_annotation()
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ Test the typing library, with docstrings and annotations
|
|||||||
"""
|
"""
|
||||||
import typing
|
import typing
|
||||||
from typing import Sequence, MutableSequence, List, Iterable, Iterator, \
|
from typing import Sequence, MutableSequence, List, Iterable, Iterator, \
|
||||||
AbstractSet, Tuple, Mapping, Dict, Union, Optional
|
AbstractSet, Tuple, Mapping, Dict, Union, Optional, Final
|
||||||
|
|
||||||
class B:
|
class B:
|
||||||
pass
|
pass
|
||||||
@@ -555,3 +555,15 @@ def typed_dict_test_foo(arg: Bar):
|
|||||||
arg['an_int']
|
arg['an_int']
|
||||||
#? int()
|
#? int()
|
||||||
arg['another_variable']
|
arg['another_variable']
|
||||||
|
|
||||||
|
# -------------------------
|
||||||
|
# Final
|
||||||
|
# -------------------------
|
||||||
|
|
||||||
|
x: Final[str] = 1
|
||||||
|
y: Final = 1
|
||||||
|
#? str()
|
||||||
|
x
|
||||||
|
# TODO
|
||||||
|
#?
|
||||||
|
y
|
||||||
|
|||||||
Reference in New Issue
Block a user