mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-06 19:23:59 +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',
|
||||
'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):
|
||||
@@ -114,7 +115,7 @@ class ProxyWithGenerics(BaseTypingClassWithGenerics):
|
||||
elif string_name == 'Type':
|
||||
# The type is actually already given in the index_value
|
||||
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.
|
||||
return self._generics_manager[0].execute_annotation()
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ Test the typing library, with docstrings and annotations
|
||||
"""
|
||||
import typing
|
||||
from typing import Sequence, MutableSequence, List, Iterable, Iterator, \
|
||||
AbstractSet, Tuple, Mapping, Dict, Union, Optional
|
||||
AbstractSet, Tuple, Mapping, Dict, Union, Optional, Final
|
||||
|
||||
class B:
|
||||
pass
|
||||
@@ -555,3 +555,15 @@ def typed_dict_test_foo(arg: Bar):
|
||||
arg['an_int']
|
||||
#? int()
|
||||
arg['another_variable']
|
||||
|
||||
# -------------------------
|
||||
# Final
|
||||
# -------------------------
|
||||
|
||||
x: Final[str] = 1
|
||||
y: Final = 1
|
||||
#? str()
|
||||
x
|
||||
# TODO
|
||||
#?
|
||||
y
|
||||
|
||||
Reference in New Issue
Block a user