summaryrefslogtreecommitdiff
path: root/rplugin/python3/deoplete/base/source.py
diff options
context:
space:
mode:
authorShougo Matsushita <Shougo.Matsu@gmail.com>2019-08-04 10:16:18 +0900
committerShougo Matsushita <Shougo.Matsu@gmail.com>2019-08-04 10:16:18 +0900
commit60df951aea7a750c6595b85f04f65be3b5f14f59 (patch)
tree8f3064e97b15c26b04e5b83ffeee068f229a47c2 /rplugin/python3/deoplete/base/source.py
parente8cab49ac99a5bb45e16a4bf24bb697163e7beaf (diff)
downloaddeoplete.nvim-60df951aea7a750c6595b85f04f65be3b5f14f59.zip
Fix typing
Diffstat (limited to 'rplugin/python3/deoplete/base/source.py')
-rw-r--r--rplugin/python3/deoplete/base/source.py38
1 files changed, 21 insertions, 17 deletions
diff --git a/rplugin/python3/deoplete/base/source.py b/rplugin/python3/deoplete/base/source.py
index ed4eb84..89cff31 100644
--- a/rplugin/python3/deoplete/base/source.py
+++ b/rplugin/python3/deoplete/base/source.py
@@ -5,21 +5,24 @@
# ============================================================================
import re
+import typing
from abc import abstractmethod
+
from deoplete.logger import LoggingMixin
-from deoplete.util import debug, error_vim
+from deoplete.util import debug, error_vim, Nvim, UserContext, Candidates
class Base(LoggingMixin):
- def __init__(self, vim):
+ def __init__(self, vim: Nvim) -> None:
self.vim = vim
self.description = ''
self.mark = ''
+ self.name = ''
self.max_pattern_length = 80
self.min_pattern_length = -1
self.input_pattern = ''
- self.input_patterns = {}
+ self.input_patterns: typing.Dict[str, str] = {}
self.matchers = ['matcher_fuzzy']
self.sorters = ['sorter_rank']
self.converters = [
@@ -28,17 +31,17 @@ class Base(LoggingMixin):
'converter_truncate_kind',
'converter_truncate_info',
'converter_truncate_menu']
- self.filetypes = []
- self.keyword_patterns = []
+ self.filetypes: typing.List[str] = []
+ self.keyword_patterns: typing.List[str] = []
self.is_debug_enabled = False
self.is_bytepos = False
self.is_initialized = False
self.is_volatile = False
self.is_silent = False
self.rank = 100
- self.disabled_syntaxes = []
+ self.disabled_syntaxes: typing.List[str] = []
self.events = None
- self.vars = {}
+ self.vars: typing.Dict[str, typing.Any] = {}
self.max_abbr_width = 80
self.max_kind_width = 40
self.max_info_width = 200
@@ -47,27 +50,27 @@ class Base(LoggingMixin):
self.matcher_key = ''
self.dup = False
- def get_complete_position(self, context):
+ def get_complete_position(self, context: UserContext) -> int:
m = re.search('(?:' + context['keyword_pattern'] + ')$|$',
context['input'])
return m.start() if m else -1
- def print(self, expr):
+ def print(self, expr: typing.Any) -> None:
if not self.is_silent:
debug(self.vim, expr)
- def print_error(self, expr):
+ def print_error(self, expr: typing.Any) -> None:
if not self.is_silent:
error_vim(self.vim, expr)
@abstractmethod
- def gather_candidates(self, context):
- pass
+ def gather_candidates(self, context: UserContext) -> Candidates:
+ return []
- def on_event(self, context):
+ def on_event(self, context: UserContext) -> None:
pass
- def get_var(self, var_name):
+ def get_var(self, var_name: str) -> typing.Optional[typing.Any]:
custom_vars = self.vim.call(
'deoplete#custom#_get_source_vars', self.name)
if var_name in custom_vars:
@@ -76,19 +79,20 @@ class Base(LoggingMixin):
return self.vars[var_name]
return None
- def get_filetype_var(self, filetype, var_name):
+ def get_filetype_var(self, filetype: str,
+ var_name: str) -> typing.Optional[typing.Any]:
var = self.get_var(var_name)
if var is None:
return None
ft = filetype if (filetype in var) else '_'
return var.get(ft, '')
- def get_input_pattern(self, filetype):
+ def get_input_pattern(self, filetype: str) -> str:
if not self.input_patterns:
return self.input_pattern
ft = filetype if (filetype in self.input_patterns) else '_'
return self.input_patterns.get(ft, self.input_pattern)
- def get_buf_option(self, option):
+ def get_buf_option(self, option: str) -> typing.Any:
return self.vim.call('getbufvar', '%', '&' + option)