Page 1 of 2

Pydantic Breaks Again Python 3.14.2

Posted: 13.12.2025 05:05
by Random Void User
Previous report solved at
https://synwrite.sourceforge.net/forums ... php?t=3159

New console output on starting up
CudaText 1.230.5.0, linux-x86_64-gtk2, fpc 3.2.3
with plug-ins up-to-date and __pycache__ deleted before start.
System Python is 3.14.2 with python3-pydantic installed.

Code: Select all

Init: cuda_lsp
Traceback (most recent call last):
  File "/opt/cudatext/py/cuda_lsp/__init__.py", line 1, in <module>
    from .lsp import Command
  File "/opt/cudatext/py/cuda_lsp/lsp.py", line 36, in <module>
    from .language import CompletionMan, DiagnosticsMan, Language
  File "/opt/cudatext/py/cuda_lsp/language.py", line 60, in <module>
    from .sansio_lsp_client import client as lsp
  File "/opt/cudatext/py/cuda_lsp/sansio_lsp_client/__init__.py", line 3, in <module>
    from .client import *
  File "/opt/cudatext/py/cuda_lsp/sansio_lsp_client/client.py", line 8, in <module>
    from .events import (
    ...<35 lines>...
    )
  File "/opt/cudatext/py/cuda_lsp/sansio_lsp_client/events.py", line 267, in <module>
    class Metadata(Event):
        message_id: int
        result: Optional[Dict[str, Any]] = None
  File "/opt/cudatext/py/cuda_lsp/lsp_modules/pydantic/main.py", line 221, in __new__
    inferred = ModelField.infer(
        name=var_name,
    ...<3 lines>...
        config=config,
    )
  File "/opt/cudatext/py/cuda_lsp/lsp_modules/pydantic/fields.py", line 504, in infer
    return cls(
        name=name,
    ...<7 lines>...
        field_info=field_info,
    )
  File "/opt/cudatext/py/cuda_lsp/lsp_modules/pydantic/fields.py", line 434, in __init__
    self.prepare()
    ~~~~~~~~~~~~^^
  File "/opt/cudatext/py/cuda_lsp/lsp_modules/pydantic/fields.py", line 544, in prepare
    self._set_default_and_type()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/opt/cudatext/py/cuda_lsp/lsp_modules/pydantic/fields.py", line 576, in _set_default_and_type
    raise errors_.ConfigError(f'unable to infer type for attribute "{self.name}"')
pydantic.errors.ConfigError: unable to infer type for attribute "result"
ERROR: Exception in CudaText for cuda_lsp.on_save_pre: ConfigError: unable to infer type for attribute "result"
Init: cuda_lsp
Traceback (most recent call last):
  File "/opt/cudatext/py/cuda_lsp/__init__.py", line 1, in <module>
    from .lsp import Command
  File "/opt/cudatext/py/cuda_lsp/lsp.py", line 36, in <module>
    from .language import CompletionMan, DiagnosticsMan, Language
  File "/opt/cudatext/py/cuda_lsp/language.py", line 60, in <module>
    from .sansio_lsp_client import client as lsp
  File "/opt/cudatext/py/cuda_lsp/sansio_lsp_client/__init__.py", line 3, in <module>
    from .client import *
  File "/opt/cudatext/py/cuda_lsp/sansio_lsp_client/client.py", line 8, in <module>
    from .events import (
    ...<35 lines>...
    )
  File "/opt/cudatext/py/cuda_lsp/sansio_lsp_client/events.py", line 267, in <module>
    class Metadata(Event):
        message_id: int
        result: Optional[Dict[str, Any]] = None
  File "/opt/cudatext/py/cuda_lsp/lsp_modules/pydantic/main.py", line 221, in __new__
    inferred = ModelField.infer(
        name=var_name,
    ...<3 lines>...
        config=config,
    )
  File "/opt/cudatext/py/cuda_lsp/lsp_modules/pydantic/fields.py", line 504, in infer
    return cls(
        name=name,
    ...<7 lines>...
        field_info=field_info,
    )
  File "/opt/cudatext/py/cuda_lsp/lsp_modules/pydantic/fields.py", line 434, in __init__
    self.prepare()
    ~~~~~~~~~~~~^^
  File "/opt/cudatext/py/cuda_lsp/lsp_modules/pydantic/fields.py", line 544, in prepare
    self._set_default_and_type()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/opt/cudatext/py/cuda_lsp/lsp_modules/pydantic/fields.py", line 576, in _set_default_and_type
    raise errors_.ConfigError(f'unable to infer type for attribute "{self.name}"')
pydantic.errors.ConfigError: unable to infer type for attribute "result"
ERROR: Exception in CudaText for cuda_lsp.on_save: ConfigError: unable to infer type for attribute "result"

Re: Pydantic Breaks Again Python 3.14.2

Posted: 13.12.2025 05:10
by main Alexey
It is known issue and we don't know how to solve it (in LSP plugin) w/o loosing Windows 7 support!
https://github.com/CudaText-addons/cuda_lsp/issues/217

you may try to update 'pydantic' lib in the LSP plugin folder (and loose Win7 support but that's ok for your Linux PC).

Re: Pydantic Breaks Again Python 3.14.2

Posted: 13.12.2025 08:11
by Random Void User
OK, so this problem persists. Windows 7 is so old that *its* users should be asked to place special libraries by hand, not the rest of us. The world has moved on. Nobody I know still runs Windows 7. People run Windows 10 or 11. Microsoft even forces auto-upgrades to Windows 11.

Furthermore, I do not quite understand ideas being floated about custom Python/library version control. This problem is solved. A beautiful tool called 'uv' exists precisely for bundling exact Python and library versions together. I see no need for custom code or manual operations. An embedded 'uv' setup seems possible. It's just a matter of pre-setting $UV_* environment variables specific to CudaText for its embedded uv.

https://realpython.com/python-uv/

Re: Pydantic Breaks Again Python 3.14.2

Posted: 13.12.2025 08:22
by main Alexey
problem with Pydantic is deeper than to 'place different lib version to a new folder'. lot of code in LSP plugin must be changed/adapted when we install Pydantic 2 (now it is 1.x).

Re: Pydantic Breaks Again Python 3.14.2

Posted: 13.12.2025 11:04
by Random Void User
Not sure that's the same thing. I believe you are writing about ways CudaText users have handled the problem. However uv specifically creates a Python environment with a specific Python version and specific library versions that all work together. One may specify all these versions very exactly. So if Python 3.14 is a problem, an earlier version can be specified. If Pydantic 2 is a problem, Pydantic 1 can be specified.

However Pydantic 2 has a backward-compatible API. Can it not work until the LSP code is ported? Using Pydantic 2 the backward-compatible API is invoked as

Code: Select all

from pydantic.v1 import
The GitHub page says directly: "Pydantic V2 also ships with the latest version of Pydantic V1 built in so that you can incrementally upgrade your code base and projects"

Code: Select all

from pydantic import v1 as pydantic_v1
So uv is not even needed. All that needs to change are import statements in extant CudaText LSP code, until ported to Pydantic 2.

Re: Pydantic Breaks Again Python 3.14.2

Posted: 13.12.2025 11:35
by main Alexey
I did not study the problem, I told about Pydantic v2 is harder because @badrelmers told so in the Github issue https://github.com/CudaText-addons/cuda_lsp/issues/217 .

uv? this is some Rust based tool, we cannot distribute this binary in Cudatext to keep low distro size, and it's not nice to suggest users to install uv. I did not study uv.

and, uv for all Cudatext's OSes - BSDs/Solaris/Haiku? will be hard to get.

Re: Pydantic Breaks Again Python 3.14.2

Posted: 13.12.2025 11:57
by Random Void User
Well, uv is not just some tool. It has lead position in Python package management these days. Search YouTube for reviews by experienced Python programmers.

Rust has broad platform support including those obscure ones. So uv would build on them.

Yes a 50+ MB binary file is too much for CudaText distribution, but could be limited to the LSP plug-in install. Only people wanting LSP would need uv. It could be downloaded from the upstream vendor, or otherwise the user could be requested to install it themselves. CudaText already depends on some "native system" Python stuff, for example, there is no reason LSP could not depend on "native system uv" too. LSP is too important for flaky libraries catering to ancient Windows 7, but uv could handle that corner case anyway.

Re: Pydantic Breaks Again Python 3.14.2

Posted: 13.12.2025 15:44
by main Alexey
offtopic: I looked at the lesson on Pydantic. very cool Py library!! rewritten in Rust in version 2. v2 needs Rust-binary library (we will have problem distributing LSP plugin on rare OSes).
uv: cool tool. maybe you suggested to install Pydantic v2 'via uv'? nice.

another approach is ok? make the CudaText package with only Pydantic v2. and install it into 'py' subdir (it is in sys.path).

Re: Pydantic Breaks Again Python 3.14.2

Posted: 13.12.2025 18:32
by Random Void User
One uses uv to make version-controlled Python environments. Version control applies to both the Python interpreter and all Python packages. So if the LSP problem is conflicting version issues, then uv would solve them. It is built to solve such problems.

That said, uv may not be optimal. (1) My OS already has a 'python3-pydantic' package, and (2) Pydantic 2 has a v1 compatibility API, so that current LSP code may work unmodified. It just needs to import Pydantic 2 "v1 API" instead of straight Pydantic 1. This solution seems to me the best for now. Explicitly, it means the user needs Pydantic 2 on his system, provided by one of OS / uv / direct Pydantic download, and then the user installs the updated LSP plug-in that runs on Pydantic 2 "v1 API" via altered import statements.

Re: Pydantic Breaks Again Python 3.14.2

Posted: 13.12.2025 19:03
by badrelmers
Random Void User
please use https://github.com/CudaText-addons/cuda_lsp to open or discuss problems with this plugin
there is already an open issue for your problem here https://github.com/CudaText-addons/cuda_lsp/issues/217 , so lets continue the discussion their, i will not answer here so we can unify the problem in one place, and to be able to follow the answers in github thanks to its multiple alerts methods, if i write here i will not receive any alert of the next answers. you will find my answer here https://github.com/CudaText-addons/cuda ... 3649714704