Skip to content

Commit

Permalink
Add mypy configuration & tweak pylint configuration. (#1128)
Browse files Browse the repository at this point in the history
  • Loading branch information
SirVer authored Nov 5, 2019
1 parent a909dee commit d894f79
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 22 deletions.
12 changes: 12 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Global options:

[mypy]
python_version = 3.7
warn_return_any = True
warn_unused_configs = True

[mypy-vim]
ignore_missing_imports = True

[mypy-unidecode]
ignore_missing_imports = True
11 changes: 9 additions & 2 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ load-plugins=
# --disable=W"
disable=
attribute-defined-outside-init,
bad-continuation,
fixme,
import-error,
missing-class-docstring,
missing-function-docstring,
missing-module-docstring,
redefined-builtin,
too-few-public-methods,
too-many-arguments,
Expand All @@ -44,7 +49,8 @@ disable=
too-many-public-methods,
too-many-return-statements,
too-many-statements,
bad-continuation,
useless-object-inheritance,



[REPORTS]
Expand Down Expand Up @@ -119,7 +125,7 @@ docstring-min-length=-1
[FORMAT]

# Maximum number of characters on a single line.
max-line-length=80
max-line-length=110

# Regexp for a line that is allowed to be longer than the limit.
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
Expand Down Expand Up @@ -169,6 +175,7 @@ ignore-mixin-members=yes
# List of classes names for which member attributes should not be checked
# (useful for classes with attributes dynamically set).
ignored-classes=SQLObject
ignored-modules=vim

# When zope mode is activated, add a predefined set of Zope acquired attributes
# to generated-members.
Expand Down
2 changes: 1 addition & 1 deletion pythonx/UltiSnips/snippet/definition/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def __init__(
self._location = location
self._context_code = context
self._context = None
self._actions = actions
self._actions = actions or {}

# Make sure that we actually match our trigger in case we are
# immediately expanded.
Expand Down
33 changes: 14 additions & 19 deletions pythonx/UltiSnips/snippet_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
"""Contains the SnippetManager facade used by all Vim Functions."""

from collections import defaultdict
from functools import wraps
from contextlib import contextmanager
import os
import platform
import traceback
import sys
import vim
import re
from contextlib import contextmanager

from UltiSnips import vim_helper
from UltiSnips import err_to_scratch_buffer
Expand Down Expand Up @@ -114,6 +111,7 @@ def jump_forwards(self):
if not self._jump():
vim_helper.command("let g:ulti_jump_forwards_res = 0")
return self._handle_failure(self.forward_trigger)
return None

@err_to_scratch_buffer.wrap
def jump_backwards(self):
Expand All @@ -123,6 +121,7 @@ def jump_backwards(self):
if not self._jump(True):
vim_helper.command("let g:ulti_jump_backwards_res = 0")
return self._handle_failure(self.backward_trigger)
return None

@err_to_scratch_buffer.wrap
def expand(self):
Expand Down Expand Up @@ -151,10 +150,10 @@ def expand_or_jump(self):
self._handle_failure(self.expand_trigger)

@err_to_scratch_buffer.wrap
def snippets_in_current_scope(self, searchAll):
def snippets_in_current_scope(self, search_all):
"""Returns the snippets that could be expanded to Vim as a global
variable."""
before = "" if searchAll else vim_helper.buf.line_till_cursor
before = "" if search_all else vim_helper.buf.line_till_cursor
snippets = self._snips(before, True)

# Sort snippets alphabetically
Expand All @@ -180,7 +179,7 @@ def snippets_in_current_scope(self, searchAll):
)
)

if searchAll:
if search_all:
vim_helper.command(
as_unicode(
(
Expand Down Expand Up @@ -231,7 +230,7 @@ def add_snippet(
ft="all",
priority=0,
context=None,
actions={},
actions=None,
):
"""Add a snippet to the list of known snippets of the given 'ft'."""
self._added_snippets_source.add_snippet(
Expand All @@ -251,7 +250,7 @@ def add_snippet(

@err_to_scratch_buffer.wrap
def expand_anon(
self, value, trigger="", description="", options="", context=None, actions={}
self, value, trigger="", description="", options="", context=None, actions=None
):
"""Expand an anonymous snippet right here."""
before = vim_helper.buf.line_till_cursor
Expand All @@ -262,8 +261,7 @@ def expand_anon(
if not trigger or snip.matches(before, self._visual_content):
self._do_snippet(snip, before)
return True
else:
return False
return False

def register_snippet_source(self, name, snippet_source):
"""Registers a new 'snippet_source' with the given 'name'.
Expand Down Expand Up @@ -294,10 +292,10 @@ def get_buffer_filetypes(self):
+ ["all"]
)

def add_buffer_filetypes(self, ft):
def add_buffer_filetypes(self, filetypes):
buf_fts = self._added_buffer_filetypes[vim_helper.buf.number]
idx = -1
for ft in ft.split("."):
for ft in filetypes.split("."):
ft = ft.strip()
if not ft:
continue
Expand Down Expand Up @@ -468,7 +466,7 @@ def _leaving_buffer(self):
terminated.
"""
while len(self._active_snippets):
while self._active_snippets:
self._current_snippet_is_done()
self._reinit()

Expand Down Expand Up @@ -612,10 +610,7 @@ def _handle_failure(self, trigger):
# Use remap mode so SuperTab mappings will be invoked.
break

if (
feedkey == r"\<Plug>SuperTabForward"
or feedkey == r"\<Plug>SuperTabBackward"
):
if feedkey in (r"\<Plug>SuperTabForward", r"\<Plug>SuperTabBackward"):
vim_helper.command("return SuperTab(%s)" % vim_helper.escape(mode))
elif feedkey:
vim_helper.command("return %s" % vim_helper.escape(feedkey))
Expand Down Expand Up @@ -774,7 +769,7 @@ def _try_expand(self, autotrigger_only=False):
@property
def _current_snippet(self):
"""The current snippet or None."""
if not len(self._active_snippets):
if not self._active_snippets:
return None
return self._active_snippets[-1]

Expand Down

0 comments on commit d894f79

Please sign in to comment.