Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement linting on change #408

Closed
kav2k opened this issue Dec 12, 2017 · 40 comments · Fixed by #1231
Closed

Implement linting on change #408

kav2k opened this issue Dec 12, 2017 · 40 comments · Fixed by #1231
Labels
area-linting feature-request Request for new features or functionality
Milestone

Comments

@kav2k
Copy link

kav2k commented Dec 12, 2017

As per this comment in #28, a new feature request:

Actually implement python.linting.lintOnTextChange, to apply linting to the unsaved buffer.

This is a desirable, if nontrivial, function.

See also #313 - if this is implemented, that should be reversed.

@kav2k
Copy link
Author

kav2k commented Dec 12, 2017

Please update #313 to point to this issue instead, so that people can vote for it.

@brettcannon
Copy link
Member

@kav2k you can leave a comment referencing this issue if you want; there shouldn't be anything requiring special privileges to do so.

@kav2k
Copy link
Author

kav2k commented Dec 12, 2017

image

Plus, it would make sense to edit the issue text, as it explicitly says "please add your vote 👍 against the following issue #28."

@brettcannon
Copy link
Member

@kav2k I removed the mention in the other issue.

@malmaud
Copy link

malmaud commented Dec 15, 2017

I'll just point out that PyCharm, atom, and sublime already have this. Most language packages for VSCode also have it. So this is really an outlier in terms of missing functionality.
Thanks!

@xguse
Copy link

xguse commented Dec 18, 2017

PS: since I cant comment on #313...

It advises:

"python.linting.lintOnSave": true,
"files.autoSave": true

As far as I can tell "files.autoSave": true is not actually an expected state for this option. I may be wrong but when I look at this, the options provide are:

 // Controls auto save of dirty files. Accepted values: 
'off', 
'afterDelay', 
'onFocusChange' (editor loses focus), 
'onWindowChange' (window loses focus). If set to 'afterDelay', you can configure the delay in 'files.autoSaveDelay'.

This is kind of crazy to me. I have to have my file write to disk every second in order to get linting while I write?

I will echo @malmaud on pointing out that this doesn't seem to be a "luxury" setting for most other languages/editors. It was quite surprising to me when I encountered this in this extension.

However, please don't misunderstand my tone: I am VERY thankful for your work so far and would like to point out that having python so well supported for the most part in VS Code was what allowed me to finally leave Atom. It have for the MOST part been a spectacular change.

So thanks.

@MikhailArkhipov
Copy link

This will be done via integration of Python analysis engine from Visual Studio. You can track the project here https://github.com/Microsoft/vscode-python/projects/7#card-8034268

@marnovo
Copy link

marnovo commented May 30, 2018

@MikhailArkhipov, any news on this?

@stlaz
Copy link

stlaz commented May 30, 2018

The effort I believe is tracked in https://github.com/Microsoft/vscode-python/projects/7 but it seems that while the development proceeds at a steady pace, new issues appear at the same rate. I wonder whether there already is a somehow-working prototype?

@brettcannon
Copy link
Member

It's still being actively worked on as @stlaz pointed out. It should be hitting limited preview "soon" 😉 . Keep an eye on https://aka.ms/pythonblog for our release notes to know when we're ready to have the public play with it and give us feedback.

@dannysanchez
Copy link

Just wanted to add my encouragement for this feature. Was thinking about switching to VS Code after an impressive demo from a buddy, but not being able to live-lint Python is a blocker for me. Best wishes to you all working on this.

@brettcannon
Copy link
Member

@boojum no update to speak of. We do our dev and spec work in the open so when there's something to update it will be on this issue.

@TG-KK

This comment has been minimized.

@jonahpearl
Copy link

"python.jediEnabled": false now gives a warning "Unknown Configuration Setting," is that workaround no longer functional?

@brettcannon
Copy link
Member

@jonahpearl that setting was dropped months ago; to turn off auto-complete you want "python.languageServer": "none" (I believe; doing this from memory).

@luabud
Copy link
Member

luabud commented Jan 28, 2021

It is "python.languageServer": "None" if you wish to turn off IntelliSense, but if you wish to use a language server that provides live linting, you can try our new and more performant language server called Pylance. If you're interested in trying it out, you can download it from the marketplace and set "python.languageServer": "Pylance" instead 😊

@jd-solanki
Copy link

I guess the lint on text change should be default like TS files. I hope vs-code provides the same for python. I mean developer won't turn on autoSave if he/she wants full control over his/her file.

With linters like mypy this is a real deal-breaker.

Some Thoughts:

  • TS is getting more popular due to its runtime error checking and other awesome features - Thanks to text change linting
  • FastAPI like python web framework also enforces using pydantic and typing. - Missing text change linting
  • We can't get most out of mypy linter - Missing text change linting
  • If other languages have it why not python?
  • autoSave is fine but what about those who don't want autosave and want full control over saving files(manually - I guess most people prefer ctrl + s rather than autosave).

Since I moved from Sublime this is the first point I disappointed from vs-code. I hope this gets implemented in vs-code because if you are not getting linting while you are doing static typing, static typing doesn't matter I guess.

Regards.

@v-ko
Copy link

v-ko commented Sep 1, 2021

It appears that the internal implementation is on an indefinite halt. Can this functionality be implemented by another extension by some chance? I, too, don't consider auto-saving a good alternative.

@brettcannon
Copy link
Member

@fusion-a yes, if you wanted to write your own extension to implement something because we are not moving fast enough then you certainly can; we have no special access to APIs or anything, so anything we can do anyone can do.

@Gabriel-p
Copy link

Is there any extension that implements this? This is a very basic functionality that is missing

@brettcannon
Copy link
Member

@Gabriel-p I'm personally not aware of any, but we have started researching this ourselves. It very well might mean we end up with separate extensions for each linter, though.

@leopons
Copy link

leopons commented Apr 7, 2022

Hi everyone, any news since September? Did anyone find another extension for this?
I've just decided to leave Atom for VScode, and what I've seen until now is just great. But this is a dealbreaker, it is just too important for me. If anyone else went through this I'm all ears for advice/hindsight

@brettcannon
Copy link
Member

Our first linter extension got announced as part of the VS Code 1.66 release: https://github.com/microsoft/vscode-pylint . If performance holds up we can consider adding this feature there. You can also turn on auto-save and that will also trigger the linter more-or-less as you type.

@NireBryce
Copy link

NireBryce commented Jun 8, 2022

I'm still pretty new at all of this stuff so I don't know if it's appropriate to add this here, but I didn't see mention in thread yet: cornflakes, the flake8 plugin, does have lintOnType, and might be a useful reference.

@brettcannon
Copy link
Member

@NireBryce
Copy link

NireBryce commented Jun 9, 2022

yep -- cornflakes' lint-on-type works and has for at least a year. I don't know how it performs on larger projects, but right now it's a pretty imperceptible delay

It breaks a bit on jupyter notebooks in the notebook view, but .py files with #%% at the top work fine

@karrtikr
Copy link

I encourage folks to check out #408 (comment) and see if it works for them.

@karthiknadig
Copy link
Member

Linting on change has be added to pylint: https://marketplace.visualstudio.com/items?itemName=ms-python.pylint , see readme for setting to enable this.

Ruff linter (which has pylint, flake8, bandit, pycodestyle, pydocstyle rules) also supports this: https://marketplace.visualstudio.com/items?itemName=charliermarsh.ruff
See astral-sh/ruff-lsp#280 for setting to enable it.

@luabud
Copy link
Member

luabud commented Oct 25, 2023

Now that we are dropping support for the built-in linting features, we will leave it up to each linting extension to support linting on change. Hence closing this.

@luabud luabud closed this as completed Oct 25, 2023
@github-actions github-actions bot removed the needs proposal Need to make some design decisions label Oct 25, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-linting feature-request Request for new features or functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.