Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Remove old python-lsp-black related code #21740

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading