pappasam/nginx-language-server

Support python 3.11

Closed this issue · 1 comments

nginx-language-server does not seem to work with Python 3.11, but it works fine with Python 3.10. I noticed this problem after upgrading my workstation from Fedora 36 to Fedora 37, which upgrades Python from 3.10 to 3.11.

Replication steps:

$ pipx install --python $(which python3.11) nginx-language-server
  installed package nginx-language-server 0.7.1, installed using Python 3.11.1
  These apps are now globally available
    - nginx-language-server
done! ✨ 🌟 ✨
$ nginx-language-server --help
Traceback (most recent call last):
  File "/home/eeowaa/.local/bin/nginx-language-server", line 5, in <module>
    from nginx_language_server.cli import cli
  File "/home/eeowaa/.local/pipx/venvs/nginx-language-server/lib64/python3.11/site-packages/nginx_language_server/cli.py", line 7, in <module>
    from .server import SERVER
  File "/home/eeowaa/.local/pipx/venvs/nginx-language-server/lib64/python3.11/site-packages/nginx_language_server/server.py", line 27, in <module>
    from .parser import DIRECTIVES, VARIABLES, nginxconf
  File "/home/eeowaa/.local/pipx/venvs/nginx-language-server/lib64/python3.11/site-packages/nginx_language_server/parser/__init__.py", line 4, in <module>
    from .data import (
  File "/home/eeowaa/.local/pipx/venvs/nginx-language-server/lib64/python3.11/site-packages/nginx_language_server/parser/data.py", line 15, in <module>
    class DirectiveDefinition(BaseModel):
  File "/home/eeowaa/.local/pipx/venvs/nginx-language-server/lib64/python3.11/site-packages/pydantic/main.py", line 369, in __new__
    cls.__signature__ = ClassAttribute('__signature__', generate_model_signature(cls.__init__, fields, config))
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/eeowaa/.local/pipx/venvs/nginx-language-server/lib64/python3.11/site-packages/pydantic/utils.py", line 231, in generate_model_signature
    merged_params[param_name] = Parameter(
                                ^^^^^^^^^^
  File "/usr/lib64/python3.11/inspect.py", line 2721, in __init__
    raise ValueError('{!r} is not a valid parameter name'.format(name))
ValueError: 'def' is not a valid parameter name
$ pipx uninstall nginx-language-server
uninstalled nginx-language-server! ✨ 🌟 ✨
$ pipx install --python $(which python3.10) nginx-language-server
  installed package nginx-language-server 0.7.1, installed using Python 3.10.9
  These apps are now globally available
    - nginx-language-server
done! ✨ 🌟 ✨
$ nginx-language-server --help                                   
usage: nginx-language-server [-h] [--version] [--tcp] [--host HOST] [--port PORT] [--log-file LOG_FILE] [-v]

Nginx language server: an LSP server for nginx.conf.

options:
  -h, --help           show this help message and exit
  --version            display version information and exit
  --tcp                use TCP server instead of stdio
  --host HOST          host for TCP server (default 127.0.0.1)
  --port PORT          port for TCP server (default 2088)
  --log-file LOG_FILE  redirect logs to the given file instead of writing to stderr
  -v, --verbose        increase verbosity of log output

Examples:

    Run from stdio: nginx-language-server

Should be resolved in the latest release!