Skip to content

Commit

Permalink
Merge pull request #21740 from remisalmon/clean-old-pylsp-black
Browse files Browse the repository at this point in the history
PR: Remove old `python-lsp-black` related code
  • Loading branch information
ccordoba12 authored Jan 29, 2024
2 parents 582251b + 4aba613 commit 41355a5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 30 deletions.
5 changes: 0 additions & 5 deletions spyder/config/lsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@
'autopep8': {
'enabled': True
},
'pylsp_black': {
# This is necessary for python-lsp-black less than 2.0.
# See python-lsp/python-lsp-black#41
'enabled': False
},
'black': {
'enabled': False,
'line_length': 79,
Expand Down
25 changes: 2 additions & 23 deletions spyder/plugins/completion/providers/languageserver/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,22 +784,8 @@ def generate_python_config(self):
# Autoformatting configuration
formatter = self.get_conf('formatting')

# This is necessary to support python-lsp-black 1 and 2 in the same
# codebase. See python-lsp/python-lsp-black#41 for details.
# TODO: Remove this in Spyder 6 to only support version 2.
old_pylsp_black = is_module_installed(
'pylsp_black', '<2.0.0', distribution_name='python_lsp_black'
)

if old_pylsp_black:
black_formatter = 'pylsp_black'
if formatter == 'black':
formatter = 'pylsp_black'
else:
black_formatter = 'black'

# Enabling/disabling formatters
formatters = ['autopep8', 'yapf', black_formatter]
formatters = ['autopep8', 'yapf', 'black']
formatter_options = {
fmt: {
'enabled': fmt == formatter
Expand All @@ -812,9 +798,7 @@ def generate_python_config(self):
# 1. The autopep8 plugin shares the same maxLineLength value with the
# pycodestyle one. That's why it's not necessary to set it here.
# 2. The yapf pylsp plugin doesn't support this yet.
if not old_pylsp_black:
# TODO: Remove this if in Spyder 6.
formatter_options['black']['line_length'] = cs_max_line_length
formatter_options['black']['line_length'] = cs_max_line_length

# PyLS-Spyder configuration
group_cells = self.get_conf(
Expand Down Expand Up @@ -891,9 +875,4 @@ def generate_python_config(self):
for fmt in formatters:
plugins[fmt].update(formatter_options[fmt])

# TODO: Remove the code in this if in Spyder 6 because it won't be
# necessary.
if old_pylsp_black:
plugins['black']['line_length'] = cs_max_line_length

return python_config
4 changes: 2 additions & 2 deletions spyder/plugins/editor/widgets/codeeditor/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
black = pytest.param(
'black',
marks=pytest.mark.skipif(
is_module_installed('python-lsp-black', '<1.2.0'),
reason="Versions older than 1.2 don't handle eol's correctly"
is_module_installed('python-lsp-black', '<2.0.0'),
reason='Versions older than 2.0 use a different entrypoint name'
)
)

Expand Down

0 comments on commit 41355a5

Please sign in to comment.