How to make Vim error list permanent using PyFlakes? - python

I want to use pep8 as my makeprg in order to check and fix my code compliance to PEP8 (Style guide for python code).
I used the command :set makeprg=pep8\ --repeat\ %, and when I do :make it works, the error list is populated and I can use :cn, :cp and :copen to navigate and see the error list in the QuickFix window.
But as soon as I change something in my python source file the errorlist becomes empty, the QuickFix window loses its content and I cannot navigate the list anymore.
I suspect that this is caused by PyFlakes, a Vim extension that highlights Python errors on-the-fly.
How can I fix it?

pyflakes has an option that should solve your problem, just put this in your ~/.vimrc :
let g:pyflakes_use_quickfix = 0
This actually stops pyflakes from using (and breaking) the quickfix window, that is good enough for me.

See this vim extension

Related

Installed Python 3.10.2 and now my Pip installs are not being found

Everything in my code was working perfectly fine up until I decided I wanted to utilize match-case in Python. Find out its only a thing in 3.10+, so I quickly install it and change it to be the interpreter in command palette.
Then I try to run my code same as before, and I'm not sure what changed but my Keyboard import is giving me 'Import "keyboard" could not be resolved'. Issues. The same issue was actually present as well with the 'from nis import match' module.
I installed keyboard initially using 'pip install keyboard' when running my 3.9 version, and legit everything was fine. This all started after I installed 3.10 (which I did from Pythons website yes); and I did add to PATH, but I dont think that would have any impact on my imports in VScode.
Confused as heck right now, please look at my screenshots for clearest explanation of what I'm facing.
Import could not be resolved
.
Module Not Found Error
.
pip3.10 show keyboard
.
My interpreter list from command palette
Any and all help appreciated, I'm extremely confused and think I've tried it all now
New Python versions use new site-packages folders. You need to reinstall everything. This is why poetry, pipenv, or requirements.txt are used
I think the linter-like extension/whatever Pylance is is the problem. Why? Because as we've tried, pip install keyboard and pip install --upgrade keyboard just confirm that the requirement is satisfied and the latest version of keyboard is already installed.
What I did was change Pylance's settings. Yes, it's not an actual error (with the code), but Pylance's problem. It just didn't see enough files in the keyboard package to satisfy its hunger, or Microsoft was just too lazy to pass more checks and update it accordingly, because however it happened, when I tried changing the setting to display an "error" at "missing imports" for fun, it didn't show errors or the default "warning" but "none", because I had run the file before I changed it back to display an error (maybe Pylance observed that when the file was run, there was no ModuleNotFoundError, and so stopped showing the warning).
I better shut now, because the setting I changed/overrode by adding it in settings.json is:
"python.analysis.diagnosticSeverityOverrides": {"reportMissingImports":"none"}
which is in:
{
...,
...,
...,
"python.analysis.diagnosticSeverityOverrides": {"reportMissingImports":"none"}
}
Here is a list of keys like "reportMissingImports" whose values you can change. These are the allowed values for the keys in python.analysis.diagnosticSeverityOverrides:
error (red squiggle)
warning (yellow squiggle)
information (blue squiggle)
none (disables the rule)
You would want to change their values only if you want to change their behaviour.
You can find settings.json by its path or by going to the settings GUI and clicking on any "Edit in settings.json" link-like button. You can also make settings.json open instead of the GUI by default.
Now, you won't see any more warnings when you import modules and can code without being anxious about the stupid warning.
Wow, So as it turns out, a solution I tried previously, to no avail is now working to solve this bizarre issue.
Simply put, I once again went to Command Palette (Ctrl+Shft+P), and looked through my interpreters I had to see what could be wrong.
Decided to click on the 'recommended' option I assumed I had been running this whole time. Turns out I was using this 'third' option as shown in the screenshot (the one not highlighted ofcourse); and it's the reason my module installs were being found on my machine, but not by the interpreter; as such giving me errors and not running the module for the program.
Simple error, but thanks to those who did help.

Python Indentation compile error

I have gotten myself into some python indenting mess. I am not a Python person but had to edit a couple of lines now a big mess. Tried notepad++ the indenting looks perfect to me, but it does not compile - keeps giving IndentationError: unexpected indent I dont know what the expectation is tabs/sapces - the columns are aligned corrctly.
Google/Stackoverflow suggested try using reindent. I have python 2.7 (its in the path) it contains reindent (uncompiled). Tried to run the command a few ways, used absolute paths etc, but did not work- cant find reindent:
>python -m C:\Python27\Tools\Scripts\reindent -d C:\Cassandra228\
apache-cassandra\pylib\cqlshlib\copyutil.py
c:\python27\python.exe: No module named C:\Python27\Tools\Scripts\reindent
How do I fix this.
Thanks
I currently solved my issue using the special character view in notepad++. There were tabs etc - once I got rid of them the code compiled.
I will check out sublime text - looks like it has better options.
Nonetheless how do we use the python reindent (or do we use it at all for this type of situation)
Thanks all,

Potentially devious behaviour of pygments´ mapping.py / Editing a pygments lexer

I'm using Windows 7, latest windows update etc.
Recently I decided to start using the minted package in LaTeX. For this, I was redirected to install pygments, which I installed through pip:
I'll run you through quickly what I did (to make sure I didn't do anything wrong):
Installed python 3.4 from this page.
easy_install pip in the windows command prompt.
pip install pygments in command prompt.
I've added the %PYTHONPATH% as well as %PYTHONPATH%\Scripts (which is where pygments operates from I've been led to believe), to the system PATH environment.
I'm typing source code from R into LaTeX, but the releases I could find do not offer the capital R syntax. If I use LaTeX code as such:
\documentclass{article}
\usepackage{minted}
\begin{document}
\begin{minted}{R} % Capital R won't function as intended with recent release
c(1,2,5,7,8)
\end{minted}
\end{document}
It won't recognise the capital R argument in minted.
Now, the lower case \begin{minted}{r} works just fine, so I've looked around on how to fix this, and found this answer.
Here it is suggested to adjust the math.py lexer (at %PYTHONPATH%\Lib\site-packages\pygments\lexers) to add an alias 'R' to current aliases. It also suggests to run _mapping.py in the same directory (%PYTHONPATH%\Lib\site-packages\pygments\lexers). Running _mapping.py has two effects:
It completely empties the file, the file size is reduced to 0 bytes and editing it with IDLE confirms an empty file.
It also yields this error message.
Not running _mapping.py won't apply my new alias to pygments. Running it, breaks pygments entirely. The error code is shown below.
I ran the LaTeX code again (with changes and _mapping.py also run), with pdfLaTeX, with arguments: $synctexoption, --enable-write18, -interaction=nonstopmode and $fullname (also in this order), I get the following error in LaTeX:
LaTeX Error: File `temp.out.pyg' not found.
Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: out.pyg)
Enter file name:
! Emergency stop.
<read *>
l.64 \end{minted}^^M
After running _mapping.py on a clean installation even (no changes made to any lexer or anything), I also run into the same problem. I'm uncertain whether the initial changes I made, changed registry values and whatnot, but I'm having serious issues applying this simple change to the pygments lexer.

Pycharm code completion works, but inserts unresolved references

Using PyCharm 3.0.1 Community the code completion works fine, but when I e.g. compelete to a method to one of the parents classes, the inserted method name then gets marked as an unresolved reference. What am I missing?
Details:
I am new to PyCharm, and test it on a (unified installed) Plone 4.3.2. The interpreter from the Installation is selected automatically, and I add the zinstance/bin/zopepy script for buildout.
I then open Products.CMFPlone-4.3.2-py2.7.egg/Products/CMFPlone/SkinsTool.py and then type
x = SkinsTool
at the bottom of the file. The code completion offers me manage_changeProperties (and shows PropertyManager). I select this, so that the line now says
x = SkinsTool.manage_changeProperties
The manage_changeProperties part is marked though. Hovering over the marked 'manage_changeProperties' now shows
Unresolved attribute reference 'manage_changeProperties' for class 'SkinsTool'
Is this a bug or am I doing something wrong (e.g. with importing the project)?
Edit: Following vape's advice I also tried on an instance. Same problem:
Auto-complete works fine:
But then the reference is unresolved:
This test was also done with 3.0.1 Professional.
Edit 2: The strucuture is the one of a standard plone installation: structure.txt. I have opened the topmost plone.4.3.2 folder.
Cheers,
Joerg
This is likely because there was an error when pycharm generated the skeletons for the plone library. Unless this is a bug, the only way to solve your problem is to delete the .idea folder inside your project. After doing so, reopen the project from the command line using charm <your project dir>. In case you have not made a command line tool for pycharm yet, this is how you do it:
Ok, the bug is fixed:
https://youtrack.jetbrains.com/issue/PY-11401
The next release will hopefully contain the fix, until then I compiled my own version.
Two things to note:
Link (or copy) the folder 'help' from the official community release into the intellij-community/python directory.
comile it from that python directory using 'ant -Didea.build.number=140.1332' (I think the actual number doesn't matter)
The result is in intellij-community/out/pycharmCE/artifacts

PyLint 1.0.0 with PyDev + Eclipse: "include-ids" option no longer allowed, breaks Eclipse integration

As noted in this question: How do I get Pylint message IDs to show up after pylint-1.0.0?
pylint 1.0.0 no longer accepts "include-ids" option. (It returns "lint.py: error: no such option: --include-ids"). Unfortunately, in the integation with PyDev/Eclipse, there is this little nugget:
"The --include-ids=y is always included...".
How to disable that argument so that Pylint will work with Eclipse?
[I know, other alternatives include installing an older version of Pylint or running pylint from command line without that option (which does work), but I'd like to have the integration with Eclipse.]
This should be already fixed in the latest nightly build. Please grab it there.
See: http://pydev.org/download.html for details on how to get it.
To make ID's appear in the Problem View on Eclispe using PyDev, make sure you use
msg-template={msg_id}:{line:3d},{column}: {obj}: {msg}
in pylintrc or on the command line options. Eclipse needs this to parse the PyLint output.
The following option works with pylint v1.4.3 under pydev v3.9.2:
--msg-template="{msg_id}:{line:3d},{column:2d}:{msg}"
Note: Don't put space(s) after the semicolons otherwise it does not work.

Categories