sublimelsp / LSP-pyright

Python support for Sublime's LSP plugin provided through microsoft/pyright.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

support python 3.10

maddanio opened this issue · comments

python 3.10 has added a slew of new typing features that lsp-pyright doesnt support because it only supports 3.3 and 3.8. newer python thus code shows with many wrong errors.

it only supports 3.3 and 3.8

pyright has nothing to do with ST's bundled Python. It's a node.js app.

https://github.com/microsoft/pyright/blob/main/docs/configuration.md

Pyright settings can also be specified in a [tool.pyright] section of a “pyproject.toml” file. A “pyrightconfig.json” file always takes precedent over “pyproject.toml” if both are present. For a sample pyproject.toml file, see below.

pythonVersion [string, optional]: Specifies the version of Python that will be used to execute the source code. The version should be specified as a string in the format "M.m" where M is the major version and m is the minor (e.g. "3.0" or "3.6"). If a version is provided, pyright will generate errors if the source code makes use of language features that are not supported in that version. It will also tailor its use of type stub files, which conditionalizes type definitions based on the version. If no version is specified, pyright will use the version of the current python interpreter, if one is present.

pyrightconfig.json

{
    "pythonVersion": "3.11"
}

pyproject.toml

[tool.pyright]

pythonVersion = "3.11"

image
image

pyright no, but the LSP-pyright plugin quite explicitly supports only those versions. at least in the settings it says so:

	"settings": {
		// Use a predefined setup from this plugin, valid values are:
		// - "": An empty string does nothing.
		// - "sublime_text": Suitable for people who are developing ST Python plugins.
		//                   The Python version which this plugin runs on will be used.
		//                   `sys.path` from plugin_host will be added into "python.analysis.extraPaths"
		//                   so ST package dependecies can be resolved by the LSP server.
		// - "sublime_text_33": Similar to "sublime_text" but Python 3.3 forced.
		// - "sublime_text_38": Similar to "sublime_text" but Python 3.8 forced.
		"pyright.dev_environment": "",
...

so where do I find those files you where referring to? I just installed the LSP-pyright package from sublime, I have no idea where these files are...

I have no idea where these files are...

Well, the project root. I even have two screenshots attached.

pyright no, but the LSP-pyright plugin quite explicitly supports only those versions. at least in the settings it says so:

	"settings": {
		// Use a predefined setup from this plugin, valid values are:
		// - "": An empty string does nothing.
		// - "sublime_text": Suitable for people who are developing ST Python plugins.
		//                   The Python version which this plugin runs on will be used.
		//                   `sys.path` from plugin_host will be added into "python.analysis.extraPaths"
		//                   so ST package dependecies can be resolved by the LSP server.
		// - "sublime_text_33": Similar to "sublime_text" but Python 3.3 forced.
		// - "sublime_text_38": Similar to "sublime_text" but Python 3.8 forced.
		"pyright.dev_environment": "",
...

That setting only updates the import path. That's all.

well, the project root. I even have two screenshots attached.

so you mean if I download this git repo? ok, so to make it work with python 3.10 i basically can not use the package installer but have to install from this repo then? and then in the (sublime) settings I give it the path to my python 3.10 executable so it finds the right imports?

well, the project root. I even have two screenshots attached.

so you mean if I download this git repo? blah...

I don't understand how you get this conclusion. Just put any of those two files in your project root. That's all.

I am not sure if that is a goal of this project, but from a user standpoint it would be nice if there where a way to support python 3.10 in the "normal" st workflow, i.e. install with packlage manager and then edit the config that you get to by using the preferences menu in st

I believe specifying which version of python is targeted by your python project is the "normal" workflow. At least that's what Python guys do.

if there where a way to support python 3.10 in the "normal" st workflow

Such as install Python 3.10 on your machine?

install with packlage manager and then edit the config that you get to by using the preferences menu in st

Sounds like a bad idea to me to couple a python project to ST (or any specific editor/IDE).

well, the project root. I even have two screenshots attached.

so you mean if I download this git repo? blah...

I don't understand how you get this conclusion. Just put any of those two files in your project root. That's all.

because I did not understand what you meant by project root obviously, no need to get rude. tbh i still dont find it very user friendly, the only indication that one can change the python version can be found by following the link tho this huge md file. anyway, still thanks since I now know what to do

We provide wrapper around pyright LSP server and you have to follow its documentation to know exactly how it works.

We don't want to duplicate its documentation as things would get out of date quickly.

ok, unfortunately it still doesnt work:
grafik

ok, unfortunately it still doesnt work: grafik

from typing import Self

ah, stupid again ;) sorry