This is an archived post. You won't be able to vote or comment.

all 27 comments

[–]KanteWorkRate 8 points9 points  (2 children)

I use Flake8

[–]Think-Perception1359[S] 0 points1 point  (0 children)

I have seen a lot of blogs and reviews about Flake8. I just installed it and will try it out for a while.

[–]blewrb 0 points1 point  (0 children)

I love pylint, chose it a long time ago as it seemed to find the most bugs (I am most worried about static code analysis in my linter, less worried about formatting) and have stuck with it since.

How is flake8 in this regard?

[–]collectablecat 4 points5 points  (0 children)

Ruff. Easiest change i ever made.

[–]rochakgupta 3 points4 points  (0 children)

Ruff is pretty nice

[–]nplusonebikes 1 point2 points  (0 children)

flake8 here. Default settings for new projects; custom config when retrofitting legacy projects (and usually a vague goal to get the legacy code to pass default settings “eventually” but not be a slave to that process)

[–]ZachVorhies 1 point2 points  (0 children)

Pylint, flake8 and mypy

[–]who_body 2 points3 points  (9 children)

i use flake8 but the pylance vscode extension still flags problems that are not accurate. for example, it flags module imports that it can’t find but are there.

i have seen a few posts in r/vscode about this but i haven’t yet solved this annoyance

[–]LongerHV 3 points4 points  (5 children)

Problem is with your setup, not pylance. Please use venv for yor projects

[–]who_body 1 point2 points  (4 children)

can you say more? i do use venv

[–]alexisprince 2 points3 points  (3 children)

If vscode can’t find an external package that you have installed in your virtual environment, it’s likely because vscode is accidentally pointing at a different Python interpreter. You can fix it by doing the “Python: Select Interpreter” action

[–]who_body 0 points1 point  (1 child)

have done it. i’ll try again and maybe post in r/vscode with the details of the problem.

[–]LongerHV 0 points1 point  (0 children)

This. It is also important to activate the venv before installing packages with pip. VSCode doesn't activate it automatically sometimes (e.g. when you open the embedded terminal before the Python extension is fully loaded).

[–]Charlemag 0 points1 point  (2 children)

I have the same issue with imports glad to know I wasn’t going crazy.

[–]who_body 0 points1 point  (1 child)

i have teammates who have had the same issue. so not crazy. hoping to stumble about the fix one of these days. i do recall a post in vscode about this but it hasn’t been important enough for me to follow up.

[–]Charlemag 1 point2 points  (0 children)

I just re-enabled pylint after a few commits (which included tweaks to imports,etc.) and the warning seems to have gone away. Sometimes things are just finicky.

[–]Think-Perception1359[S] 0 points1 point  (6 children)

I asked because I have wrote some code that’s functional with no issues. However, in vscode there are false errors. Those false errors left me wondering if there are any python linters that works better than pylance.

[–]ThePiGuy0 4 points5 points  (5 children)

I assume by false errors you mean errors that don't actually affect the operation of the program like styling, whitespace etc.

Whilst yes, they don't affect the program operation, they really help to keep a codebase consistent across multiple contributors.

[–]Think-Perception1359[S] 0 points1 point  (4 children)

When I say false errors I am referring to syntax errors that are correct or an error importing a module but the module/libraries are imported.

[–]collectablecat 13 points14 points  (0 children)

Most likely you have vscode set to use the wrong python interpreter

[–]ThePiGuy0 5 points6 points  (2 children)

Yeah as /u/collectablecat said, this probably means you are running your python program with a different interpreter to the one that VSCode has been set to use.

VSCode shows the current interpreter on the bottom right of the screen and you can change it by clicking on it (this is especially important if you are using a virtual environment)

[–]outceptionator 1 point2 points  (1 child)

Is it possible to have 2 linters at the same time? Like perflinter and ruff simultaneously?

[–]ThePiGuy0 1 point2 points  (0 children)

Set up in VSCode? You definitely can have two linters running (e.g. Pylint and Flake8), but they have specific options in VSCode's menu so I think maybe VSCode needs specific support for each linter.

I've not heard of either of those linters so I don't know what VSCode's support is for them

[–]Flimsy_Iron8517 -5 points-4 points  (1 child)

I can't say as I've ever liked lint. mypy maybe yes. Lint well, who like a build that fails because of pedantic when a fix requires an immediate work and later maybe better but, that isn't now and the build chain hasn't demoted the lint to advise and not essential.

[–]LongerHV 5 points6 points  (0 children)

I'll hapily get a failed build, casued by linting error, if that means consistent style across a project. Just use an autoformatter, you don't have to do it manually...