microsoft / vscode-flake8

Linting support for python using the flake8 library.
https://marketplace.visualstudio.com/items?itemName=ms-python.flake8
MIT License
40 stars 30 forks source link

Python version 3.6 is not supported. #323

Closed petrosschilling closed 2 months ago

petrosschilling commented 2 months ago

Diagnostic Data

Behaviour

Expected Behavior

I have the extension installed in the vscode I have flake8 installed in my virtual environment I have the python interpreter set to my virtual environment.

when I start the flake8 server It should not fail due to python version.

Actual Behavior

when I start the flake8 server It fails due to python version.

Reproduction Steps:

Install pyenv install python 3.6.15 using pyenv set global version to 3.6.15 create new project create virtual environment using python 3.6.15 install flake8 (any version supported by python 3.6.15) See server require python 3.8

Logs:

Steps to set log level to trace and view:

2024-06-12 11:01:51.213 [info] No interpreter found from setting flake8.interpreter
2024-06-12 11:01:51.213 [info] Getting interpreter from ms-python.python extension for workspace /Users/petrosschilling/dev/crm
2024-06-12 11:01:51.215 [error] Python version 3.6 is not supported.
2024-06-12 11:01:51.215 [error] Selected python path: /Users/petrosschilling/dev/crm/env/bin/python
2024-06-12 11:01:51.215 [error] Supported versions are 3.8 and above.
2024-06-12 11:01:51.216 [info] No interpreter found for /Users/petrosschilling/dev/crm in settings or from ms-python.python extension
2024-06-12 11:01:51.216 [error] Python interpreter missing:
[Option 1] Select python interpreter using the ms-python.python.
[Option 2] Set an interpreter using "flake8.interpreter" setting.
 Please use Python 3.8 or greater.

Outcome When Attempting Debugging Steps:

Did running it from the command line work? Yes

Extra Details

settings.json:

{
    "editor.defaultFormatter": null,
    "python.languageServer": "Pylance",
    "[python]": {
        "editor.defaultFormatter": "ms-python.black-formatter",
        "editor.formatOnType": true,
        "editor.formatOnSave": true,
    },
    "black-formatter.args": [
        "--line-length",
        "120"
    ],
    "python.createEnvironment.trigger": "off",
    "python.terminal.activateEnvironment": false,
    "python.analysis.autoImportCompletions": true,
}
karthiknadig commented 2 months ago

This is by design. We don't support out of service versions of python. If you can update please update your python. Python 3.6 has been out of support for 2 years, and python 3.7 is out of support for about 9 months. Python 3.8 will be out of service in October. see https://devguide.python.org/versions/#versions

petrosschilling commented 2 months ago

Hey @karthiknadig thanks for the reply. I know 3.6 has been out of support for a while.

I can't upgrade to a newer version for the current project I'm working on unfortunately.

What I don't understand is why drop the support for python 3.6? Shouldn't I be able to just use and older version of Flake8 that works with the current Python version I'm using?

Maybe dropping the support is a requirement for reasons I don't understand. But it just feels wrong as some projects can't be upgraded that easily to a newer python version.

According to the link you mentioned: " end-of-life: release cycle is frozen; no further changes can be pushed to it. " As the quote says, no further changes can be pushed to it. Not "Drop support for tools that should be working with that current python version"

Looks like the check for version is there for no reason whatsoever than to force people to upgrade. because if I change the export const PYTHON_MINOR = 8; to export const PYTHON_MINOR = 6; it works just fine.

If is not to force the developer to upgrade, what is this version check here for?

export function checkVersion(resolved: ResolvedEnvironment | undefined): boolean {
    const version = resolved?.version;
    if (version?.major === PYTHON_MAJOR && version?.minor >= PYTHON_MINOR) {
        return true;
    }
    traceError(`Python version ${version?.major}.${version?.minor} is not supported.`);
    traceError(`Selected python path: ${resolved?.executable.uri?.fsPath}`);
    traceError(`Supported versions are ${PYTHON_VERSION} and above.`);
    return false;
}

I hope you can clarify these questions.. I'm sure the maintainers team have their reasons to have added a check for the python version.

karthiknadig commented 2 months ago

This extension depends on packages that dropped support of Python 3.6, this happened when they migrated to support Python 3.11 and 3.12. See for example this package we depend on: https://pypi.org/project/cattrs

You have two options:

  1. [Option 1] You can use ”flake8.path”: ["<path-to-flake8-bin>”] (. this would be your flake8 installed in Python 3.6 env), and you can point ”flake8.interpreter": ["<python-3.8-path>”]. This way the extension will use newer Python, but will still pose older flake8.
  2. [Option 2] You can use older version of Python extension from 2022 which supported Python 3.6.
petrosschilling commented 2 months ago

I see, thanks for the clarification.

Managed to get this working by downgrading the extension.

I will close this issue then.

Thanks again.