Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import logging
import os
import re
import sys
import pydocstyle
from pyls import hookimpl, lsp
log = logging.getLogger(__name__)
# PyDocstyle is a little verbose in debug message
pydocstyle_logger = logging.getLogger(pydocstyle.utils.__name__)
pydocstyle_logger.setLevel(logging.INFO)
DEFAULT_MATCH_RE = pydocstyle.config.ConfigurationParser.DEFAULT_MATCH_RE
DEFAULT_MATCH_DIR_RE = pydocstyle.config.ConfigurationParser.DEFAULT_MATCH_DIR_RE
@hookimpl
def pyls_settings():
# Default pydocstyle to disabled
return {'plugins': {'pydocstyle': {'enabled': False}}}
@hookimpl
def pyls_lint(config, document):
settings = config.plugin_settings('pydocstyle')
log.debug("Got pydocstyle settings: %s", settings)
# Explicitly passing a path to pydocstyle means it doesn't respect the --match flag, so do it ourselves
filename_match_re = re.compile(settings.get('match', DEFAULT_MATCH_RE) + '$')
if not filename_match_re.match(os.path.basename(document.path)):
import logging
import os
import re
import sys
import pydocstyle
from pyls import hookimpl, lsp
log = logging.getLogger(__name__)
# PyDocstyle is a little verbose in debug message
pydocstyle_logger = logging.getLogger(pydocstyle.utils.__name__)
pydocstyle_logger.setLevel(logging.INFO)
DEFAULT_MATCH_RE = pydocstyle.config.ConfigurationParser.DEFAULT_MATCH_RE
DEFAULT_MATCH_DIR_RE = pydocstyle.config.ConfigurationParser.DEFAULT_MATCH_DIR_RE
@hookimpl
def pyls_settings():
# Default pydocstyle to disabled
return {"plugins": {"pydocstyle": {"enabled": False}}}
@hookimpl
def pyls_lint(config, document):
settings = config.plugin_settings("pydocstyle")
log.debug("Got pydocstyle settings: %s", settings)
# Explicitly passing a path to pydocstyle means it doesn't respect the --match flag, so do it ourselves
filename_match_re = re.compile(settings.get("match", DEFAULT_MATCH_RE) + "$")
if not filename_match_re.match(os.path.basename(document.path)):