Skip to content

Formatter server crashes with bundled libs on Python 3.11 #67

@Bobronium

Description

@Bobronium

Steps to reproduce

  1. Make sure extension uses Python3.11
  2. Open python project without pydantic installed
  3. Observe server crash

Reason

Bundled version of pydantic is outdated, doesn't officialy support python 3.10 and crashes on 3.11
https://github.com/samuelcolvin/pydantic/pull/2885/files#diff-75ec66ee30c88591d87f430102cfbba45e2e0e31a50df8ab4862f03edc6d4072R237

Solution

  • add pydantic to the requirements
    or
  • fix version of pydantic installed with pygils (in pygils repo)
Formatter Name: Black
Formatter Module: black
Traceback (most recent call last):
  File "/Users/bobronium/.vscode/extensions/ms-python.black-formatter-2022.1.11451003/bundled/formatter/format_server.py", line 19, in <module>
    from pygls import lsp, protocol, server, uris, workspace
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bobronium/.vscode/extensions/ms-python.black-formatter-2022.1.11451003/bundled/libs/pygls/lsp/__init__.py", line 23, in <module>
    from pygls.lsp.types import *
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bobronium/.vscode/extensions/ms-python.black-formatter-2022.1.11451003/bundled/libs/pygls/lsp/types/__init__.py", line 2, in <module>
    from pygls.lsp.types.basic_structures import *
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bobronium/.vscode/extensions/ms-python.black-formatter-2022.1.11451003/bundled/libs/pygls/lsp/types/basic_structures.py", line 30, in <module>
    from pydantic import BaseModel, root_validator
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bobronium/.vscode/extensions/ms-python.black-formatter-2022.1.11451003/bundled/libs/pydantic/__init__.py", line 2, in <module>
    from . import dataclasses
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bobronium/.vscode/extensions/ms-python.black-formatter-2022.1.11451003/bundled/libs/pydantic/dataclasses.py", line 7, in <module>
    from .main import create_model, validate_model
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bobronium/.vscode/extensions/ms-python.black-formatter-2022.1.11451003/bundled/libs/pydantic/main.py", line 376, in <module>
    class BaseModel(Representation, metaclass=ModelMetaclass):
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bobronium/.vscode/extensions/ms-python.black-formatter-2022.1.11451003/bundled/libs/pydantic/main.py", line 369, in __new__
    cls.__signature__ = ClassAttribute('__signature__', generate_model_signature(cls.__init__, fields, config))
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bobronium/.vscode/extensions/ms-python.black-formatter-2022.1.11451003/bundled/libs/pydantic/utils.py", line 235, in generate_model_signature
    if config.extra is config.extra.allow:
                       ^^^^^^^^^^^^^^^^^^
  File "/Users/bobronium/.pyenv/versions/3.11.0a7/lib/python3.11/enum.py", line 169, in __get__
    raise AttributeError(
    ^^^^^^^^^^^^^^^^^^^^^
AttributeError: <enum 'Extra'> member has no attribute 'allow'
[Info  - 1:30:39 PM] Connection to server got closed. Server will restart.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue identified by VS Code Team member as probable bugneeds investigation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions