forked from VimPlug/jedi
Introduce some stricter typing
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from abc import abstractmethod
|
||||
from contextlib import contextmanager
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
from typing import Optional, Any
|
||||
|
||||
from parso.python.tree import Name
|
||||
|
||||
@@ -16,6 +16,8 @@ from jedi import parser_utils
|
||||
|
||||
class AbstractContext:
|
||||
# Must be defined: inference_state and tree_node and parent_context as an attribute/property
|
||||
tree_node: Any
|
||||
parent_context: Any
|
||||
|
||||
def __init__(self, inference_state):
|
||||
self.inference_state = inference_state
|
||||
@@ -218,6 +220,13 @@ class ValueContext(AbstractContext):
|
||||
|
||||
|
||||
class TreeContextMixin:
|
||||
tree_node: Any
|
||||
is_module: Any
|
||||
get_value: Any
|
||||
inference_state: Any
|
||||
is_class: Any
|
||||
parent_context: Any
|
||||
|
||||
def infer_node(self, node):
|
||||
from jedi.inference.syntax_tree import infer_node
|
||||
return infer_node(self, node)
|
||||
@@ -300,7 +309,6 @@ class TreeContextMixin:
|
||||
class FunctionContext(TreeContextMixin, ValueContext):
|
||||
def get_filters(self, until_position=None, origin_scope=None):
|
||||
yield ParserTreeFilter(
|
||||
self.inference_state,
|
||||
parent_context=self,
|
||||
until_position=until_position,
|
||||
origin_scope=origin_scope
|
||||
|
||||
Reference in New Issue
Block a user