Skip to content

Commit

Permalink
Specify relevant document path when retrieving some plugin settings (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mnauw authored Oct 25, 2020
1 parent e0f8b3d commit 6c9aca4
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions pyls/plugins/autopep8_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def pyls_format_range(config, document, range): # pylint: disable=redefined-bui


def _format(config, document, line_range=None):
options = _autopep8_config(config)
options = _autopep8_config(config, document)
if line_range:
options['line_range'] = list(line_range)

Expand Down Expand Up @@ -57,9 +57,10 @@ def _format(config, document, line_range=None):
}]


def _autopep8_config(config):
def _autopep8_config(config, document=None):
# We user pycodestyle settings to avoid redefining things
settings = config.plugin_settings('pycodestyle')
path = document.path if document is not None else None
settings = config.plugin_settings('pycodestyle', document_path=path)
options = {
'exclude': settings.get('exclude'),
'hang_closing': settings.get('hangClosing'),
Expand Down
2 changes: 1 addition & 1 deletion pyls/plugins/flake8_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def pyls_settings():
@hookimpl
def pyls_lint(workspace, document):
config = workspace._config
settings = config.plugin_settings('flake8')
settings = config.plugin_settings('flake8', document_path=document.path)
log.debug("Got flake8 settings: %s", settings)

opts = {
Expand Down
2 changes: 1 addition & 1 deletion pyls/plugins/mccabe_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@hookimpl
def pyls_lint(config, document):
threshold = config.plugin_settings('mccabe').get(THRESHOLD, DEFAULT_THRESHOLD)
threshold = config.plugin_settings('mccabe', document_path=document.path).get(THRESHOLD, DEFAULT_THRESHOLD)
log.debug("Running mccabe lint with threshold: %s", threshold)

try:
Expand Down
2 changes: 1 addition & 1 deletion pyls/plugins/pycodestyle_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
@hookimpl
def pyls_lint(workspace, document):
config = workspace._config
settings = config.plugin_settings('pycodestyle')
settings = config.plugin_settings('pycodestyle', document_path=document.path)
log.debug("Got pycodestyle settings: %s", settings)

opts = {
Expand Down
2 changes: 1 addition & 1 deletion pyls/plugins/pydocstyle_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def pyls_settings():

@hookimpl
def pyls_lint(config, document):
settings = config.plugin_settings('pydocstyle')
settings = config.plugin_settings('pydocstyle', document_path=document.path)
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
Expand Down

0 comments on commit 6c9aca4

Please sign in to comment.