GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix compatibility with black≥26.5 by musicinmybrain · Pull Request #65 · python-lsp/python-lsp-black

Conversation

@musicinmybrain

@musicinmybrain musicinmybrain commented Jul 14, 2026

Copy link
Copy Markdown

The black.parsing.SourceASTParseError exception type was split out from black.parsing.ASTSafetyError in black 26.5.0, psf/black#5080.

This fixes:

========================================================================================= FAILURES ==========================================================================================
__________________________________________________________________________ test_pylsp_format_document_syntax_error __________________________________________________________________________

>   ???

src/black/__init__.py:1636:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   ???
E   SyntaxError: unexpected indent (<unknown>, line 1)

src/black/parsing.py:162: SyntaxError

During handling of the above exception, another exception occurred:

config = <pylsp.config.config.Config object at 0x7ff7e753de00>, invalid_document = <pylsp.workspace.Document object at 0x7ff7e7545f20>

    def test_pylsp_format_document_syntax_error(config, invalid_document):
>       result = pylsp_format_document(config, invalid_document)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/test_plugin.py:179:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pylsp_black/plugin.py:38: in pylsp_format_document
    return format_document(config, document)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pylsp_black/plugin.py:73: in format_document
    formatted_text = format_text(text=text, config=config, lines=lines)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pylsp_black/plugin.py:114: in format_text
    formatted_text = black.format_file_contents(
src/black/__init__.py:1124: in format_file_contents
    ???
src/black/__init__.py:1089: in check_stability_and_equivalence
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   ???
E   black.parsing.SourceASTParseError: cannot use --safe with this file; failed to parse source file AST: unexpected indent (<unknown>, line 1)
E   This could be caused by running Black with an older Python version that does not support new syntax used in your source file.

src/black/__init__.py:1638: SourceASTParseError
___________________________________________________________________________ test_pylsp_format_range_syntax_error ____________________________________________________________________________

>   ???

src/black/__init__.py:1636: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   ???
E   SyntaxError: unexpected indent (<unknown>, line 1)

src/black/parsing.py:162: SyntaxError

During handling of the above exception, another exception occurred:

config = <pylsp.config.config.Config object at 0x7ff7e75433e0>, invalid_document = <pylsp.workspace.Document object at 0x7ff7e74d19b0>

    def test_pylsp_format_range_syntax_error(config, invalid_document):
        range = {"start": {"line": 0, "character": 0}, "end": {"line": 1, "character": 0}}
    
>       result = pylsp_format_range(config, invalid_document, range=range)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/test_plugin.py:253:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pylsp_black/plugin.py:46: in pylsp_format_range
    return format_document(config, document, range)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pylsp_black/plugin.py:73: in format_document
    formatted_text = format_text(text=text, config=config, lines=lines)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pylsp_black/plugin.py:114: in format_text
    formatted_text = black.format_file_contents(
src/black/__init__.py:1124: in format_file_contents
    ???
src/black/__init__.py:1089: in check_stability_and_equivalence
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   ???
E   black.parsing.SourceASTParseError: cannot use --safe with this file; failed to parse source file AST: unexpected indent (<unknown>, line 1)
E   This could be caused by running Black with an older Python version that does not support new syntax used in your source file.

src/black/__init__.py:1638: SourceASTParseError
===================================================================================== warnings summary ======================================================================================
tests/test_plugin.py:8
  /home/ben/src/forks/python-lsp-black/tests/test_plugin.py:8: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
    import pkg_resources

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================================== short test summary info ==================================================================================
FAILED tests/test_plugin.py::test_pylsp_format_document_syntax_error - black.parsing.SourceASTParseError: cannot use --safe with this file; failed to parse source file AST: unexpected indent (<unknown>, line 1)
FAILED tests/test_plugin.py::test_pylsp_format_range_syntax_error - black.parsing.SourceASTParseError: cannot use --safe with this file; failed to parse source file AST: unexpected indent (<unknown>, line 1)
========================================================================== 2 failed, 19 passed, 1 warning in 0.38s ==========================================================================

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
haplo
haplo reviewed Jul 14, 2026
View reviewed changes
Comment thread pylsp_black/plugin.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@musicinmybrain
Fix compatibility with black≥26.5
35b5bc6
@musicinmybrain
musicinmybrain force-pushed the black26.5 branch from fd71a2d to 35b5bc6 Compare July 14, 2026 13:27
@djacu djacu mentioned this pull request Jul 20, 2026
python314Packages.python-lsp-black NixOS/nixpkgs#543713
Merged
4 of 13 tasks
@djacu

djacu commented Jul 20, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Carried this downstream in nixpkgs (NixOS/nixpkgs#543713) to unblock python-lsp-black and spyder on black 26.5. It builds cleanly there against black 26.5.1. Would be great to get it merged / into a release. Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@haplo

haplo commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

I apologize for not being more responsive.

The reality is that I moved to ruff over black a while ago and have not been using python-lsp-black any longer. That coupled with the Summer vacation is going to delay my reviewing and testing of these PRs.

@ccordoba12 would you have any bandwidth for this?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@haplo haplo haplo left review comments

At least 1 approving review is required to merge this pull request.

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@musicinmybrain @djacu @haplo
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.