How to disable squiggly lines underline in VSC 1.49.2? - python

Please help, it's driving me nuts. I tried following another older stack overflow post and it didn't work. I just declare a new variable and I already get squiggly line - what an annoying feature. Using python by the way on VSC.
Something like this:
My json.settings look like this:

Based on the information you provided, I reproduced the problem.
The reason is that Python's code analysis tool Pylint detects that the variable "words_to_remove" is not used, so it displays "Pylint(Unused variable)".
Solution:
Complete the code. for example:
Turn off the prompt of Pylint.
1). Close the "Unused variable" prompt of pylint:
Please use "python.linting.pylintArgs": ["--disable=W0612"], in settings.json:
2). Close Pylint.
Use "python.linting.enabled":false , in settings.json.
In addition, Pylint is an excellent Python code analysis tool. It will provide good suggestions on the format and syntax of the code we edit and it does not affect the execution of the code.
Therefore, if you want to turn off Pylint related prompts to remove the wavy lines, it is better to set it off after the code can be executed.

Related

How to change the way pylint lints the comments

I need to have this line in the beginning of a python file:
#script_exec_time: 500
There should not be any space between the # and script_exec_time. This is because the python file is parsed by another script and it will not consider the script_exec_time if there is a space.
I cannot modify the script that parses my python file because I do not have access to it.
Now when I lint using pylint, it automatically gives a space between the # and script_exec_time.
I tried using other linters like flake8, but even they do the same thing.
I still want to use the linter because it makes it much easier to code.
Is there any way to modify pylint settings so that it ignores comments from it's automatic formatting? Or is there any workaround I could use here?
Edit: I tried the same thing by disabling the linter. The problem persisted. It was not related to linter I think. Anyway I found a workaround and I am posting that as an answer.
As Vaibhav Vishal pointed out in his comment, linters like Pylint and flake8 do not reformat code, they just flag code that triggers a lint rule.
You most likely have a formatter installed and configured. See the formatting docs on how this is done and basically do the reverse. :)
All I did was to wrap the original comment in side a block comment, like so:
#script_exec_time:5000
'''
#scrript_exec_time:5000
'''
Vscode will not format anything that is there inside the block comments.

PyCharm code completion works in console but not editor

When typing the following code into the editor window, only some of the available items for autocomplete show up. That is to say that it should show .loc as an option but doesn't.
import pandas as pd
df = pd.read_csv('somecsvfile.csv')
df.
code completion in editor window
When using the console in PyCharm with the same code, the full list shows up. (See the attached images)
code completion with the full list
I have invalidated caches and restarted. Further, it seems like another recommendation was to turn on Python Debugger -> Collect run-time types information for code insight. I did that as well and still nothing when in the editor window.
What really confuses me is that the code completion works in the console, but not the editor.
Any help would be greatly appreciated!
When you run it in the console it knows the type of df because it actually has it right there. It can even run dir(df) to know exactly what names are available. In the editor it isn't running the code so it has to guess the type by inspecting pd.read_csv which is much harder (often even impossible) because Python is so dynamic.
I used to have this same problem. This was only happening for me in Linux. Note that this is possible and actually standard behavior in windows, so it can be done. Not sure if it is done using static analysis or a similar method.
I have since been able to fix it, I think what did it was defining the correct interpreter not only in the running/debugging configuration, but also in the defaults of the project (check File-->settings-->Project Interpreter and File-->default settings-->Project Interpreter)
I have now moved to the next problem, which is that auto-complete works for Python Console and File editing, but weirdly enough does not work for Debugging!...

syntastic with python no warnings and error arrows

I have following vimrc, but I do not get arrows for warnings and error from syntastic
like on the picture below
Further more I am not able to use the ruler with set ruler. Why I do not get a warning that variable "a" is not used?
What did I do wrong?
Thank you in advance.
Syntastic is checking your code for compliance with PEP8.. This is a recommendation usually followed by the Python community around formatting your code.
The first error is because you did import os but then you don't actually call any methods from os in your code since that line is commented out. You shouldn't import modules you don't use.
The second is because PEP8 specifies that you should have 2 blank lines between the imports and the start of your code.
The third is because PEP8 also says there should be no trailing whitespace.
As far as the ruler goes, I'm not exactly sure as to what you're referring.

introspective code completion with VIM? ... or other lightweight editor with this feature?

I've been all over the web trying to find a way to get VIM to have code completion similar to PyDev. It doesn't seem like it is possible!
-I have tried to use the omnicompletion suggested at this link: http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/ .
-I have tried several addons to alleviate the problem, none work.
The "omnicomplete" functionality is NOT what I am looking for. It just takes all the words in the file you are working on and uses those to try and complete what I am doing. For example if I wrote:
import numpy
a_single_array = range(100)
np.a#[then I hit cntrl+n to code complete]
It would spit out "a_single_array" as a possible completion -- but that is absurd! That is not a valid completion for "numpy.a ..."
What is the issue here? All the addon would have to do is run a dir(work you want to find) from the folder you are in and then filter the output! This cannot be that difficult! (I suppose you would also have to read the file you are currently editing and filter that as well to take note of name changes... but that's pretty much it!)
Speaking of how easy it would be... if there isn't anything already made, I was thinking of writing the script myself! Any guides on how to do THAT?
No, the omni completion functionality is EXACTLY what you are looking for.
You are using <C-n> instead of <C-x><C-o>:
type <C-n> & <C-p> to complete with words from the buffer (after and before the cursor respectively)
type <C-x><C-o> to complete method/properties names
It's specifically explained in the article you linked:
In V7, VIM introduced omni completion – given it is configured to recognize Python (if not, this feature is only a plugin away) Ctrl+x Ctrl+o opens a drop down dialog like any other IDE – even the whole Pydoc gets to be displayed in a split window.
Ctrln is insert-completion.
Ctrlx Ctrlo is omni-completion.
I remap omnicompletion to CtrlSpace:
inoremap <C-Space> <C-x><C-o>
You could also try SuperTab.
I have no idea about the various completion options for Python in Vim. But if you want to roll your own you'd be well advised to study and modify one of the existing ones, like this:
http://www.vim.org/scripts/script.php?script_id=1542
Also, if all your omnicompletion is doing is listing words in current file then you don't have it set up properly for Python-specific completion. . . . Not sure how good the specialized Python completion systems get, but they certainly does compete based on Python units external to your current file. . . .

pydev - can someone please explain these errors

I am developing using PyDev in Eclipse. I have put in some comments in my code. I get wavy red lines underneath certain words. The program runs fine and there are no warnings mentioned. So what is the meaning of these wavy lines.
e.g.
#!/usr/bin/python - I get the line under usr and python
# generated by accessing registry using another script written in VBScript.
# The scripts can do the follwing things.
- I get wavy lines under the words registry and following.
I need these comments as I may run the module on its own later.
Thanks for the help.
Neil speaks the truth, except for telling you to turn it off -- spell check in comments is quite helpful -- those who come after will thank you for ensuring they can read your comments without trying to decode random spelling errors.
The lines are simply pointing out words your IDE thinks are spelled wrong. I don't know why it doesn't understand "registry", but you have, in fact, misspelled "following" (as "follwing"). Fix the latter, ignore the former (or add it to the dictionary, don't remember if there's a convenient mechanism for that There is! See Macke's helpful comment below.).
Might be this is just a spellchecker. You have a typo "follwing" instead of "following".

Categories