I has Sublime Text 3 installed, SublimeLinter plugin and pyflakes linter.
In the pip pyflakes version is 1.6.0. OS win 7 x86.
my_name = 'Name'
print(f"My name is {my_name}.")
And here is the error:
SublimeLinter: pyflakes output:
ex3.py:9:30: invalid syntax
print(f"My name is {my_name}.")
^
Also, with this construction i have no errors:
print("My name is {}.".format(my_name))
Code is runing just fine, but why pyflakes gives me this error then? Is it pyflakes issue or what?
This is a known issue, see here:
https://gitlab.com/pycqa/flake8/issues/296
It seems to be fixed in current version...
Edit: Since you are on the latest version, maybe you are running into an issue of sublime-linter, like here:
https://forum.sublimetext.com/t/sublimelinter-pyflakes-not-matching-pyflakes-from-cli/31348/3
To test this, you could run the pyflakes command in the command line outside of sublime to see whether it works.
Edit2: As per the asker's comment, using SublimeLinter-flake8 instead of SublimeLinter-pyflakes is compatible with f-strings from python 3.6+.
(Also, sorry for the double posted answer. And thanks for deleting one, #Andy. I don't know what happened there.)
So, the best way is to use SublimeLinter-flake8 instead of SublimeLinter-pyflakes with python 3.6+, cause pyflakes linter is not compatable with 3.6 yet. Also flake8 do the same as pyflakes and much more.
Related
I'd like to be able to either increase the max linelength or tell the code formatting checkers to ignore E501. Previous solutions are very old, but more importantly, do not work for me. I just installed eclipse:
Version: 2022-06 (4.24.0)
Build id: 20220609-1112
Code formatter settings:
autopep8
--ignore=E501 --max-line-length=110
Pydev
python 3.10
using pylint
Also, I'm running in a virtual python environment
Please let me know if other info is needed.
I can't seem to get autopep8 (or pylint if that is possible) to take any inputs.
I conclude there is no way to suppress or modify pep8 telling you that your linelength is longer than 80 characters as I've had zero solutions recommended. I also conclude that pep8 is not being actively worked on.
I went through multiple SO questions but couldn't find a solution for my problem. I am new to Python and following is my setup,
VSCode: version 1.45
Python : 3.8.2
Pylint: 2.5.3
autopep8: 1.5.3
pycodestyle: 2.6.0
With the above setup, if I want to enforce PEP8 naming conversions what should I do? The VScode documentation provide how to configure pydocstyleargs but it's documentation does not cover naming conventions.
I also looked at the things autopep8 fixes and can configure via "python.formatting.autopep8Args", it doesn't fix/report things like classes not having pascal-case
As mentioned by #PyWalker2797, I tried installing pep8 and enable it by setting "python.linting.pep8Enabled": true. But VSCode doesn't recognise it even after a restart of the application.
I had the same problem.
If you read the documentation you will notice that the setting is not called pep8 but resides under the pydocstyle superset.
Thus, you have to use the following setting to enable checks on the variable conventions (and other stuff) from pep8:
"python.linting.pycodestyleEnabled": true,
Install pep8 and pylint using pip:
pip install pep8
pip install pylint
Then get your settings.json file, and add the line:
"python.linting.pep8Enabled": true
I've been looking for a little time now, and can't find an answer to my problem.
I'm coding on vim and I tried the new format string version f'whatever {a_var}', but my flake8 / syntastic keep telling me that's a syntax error.
Do you have any idea on how to fix this ?
I already had a problem with vim-jedi for python3.6 and virtualenv, and after hours of research I found a hack in some github issue, but here I can't find anything.
Thanks in advance for your help.
You have to verify that your flake8 script uses python3.6. Run which flake8 in command line, open the file in vim (or directly run vim $(which flake8)) and see the shebang line (the first line of the file, it starts with #!). If it's not python3.6 — edit the line.
I want pylint to use python3 for linting in Visual Studio code on Mac (which has both python 2.7 standard and python 3.6).
I've tried changing the path to the python interpreter as per How can I debug Python3 code in Visual Studio Code, to no avail. I keep getting python2 errors instead of python3 errors.
See example code for the problem.
Is there a way I can get pylint to recognize python3 errors?
Pick a xx.py in Visual Studio Coce(VSC)
In Status Bar Tap Python 2.7.10 like the [img1]
Choose python 3.x like [img2]
Command+Q quit VSC, then open VSC again
I finally got it working by installing python3 pylint from the console.
sudo python3 -m pip install -U pylint
The simple solution is to just change the first line of the file /home/user_name/.local/bin/pylint from #!/usr/bin/python2 to #!/usr/bin/python3
If you want more, you can rename this file to pylint2 and have a copy pylint3 where you change the first line to #!/usr/bin/python3.
Now to use pylint3 from command line you just need to type pylint3 instead of pylint.. also change the directory of pylinter in vscode to /home/user_name/.local/bin/pylint3
explanation
Ok this might be very late and the answer might not be the optimum, but I had the same issue.
By default the path to pylint is /home/user_name/.local/bin/pylint that is a simple python script working as the entry point to pylint.. even after installing pylint using pip3 this file is not changed and keeps directing to use python2 and therefore the packages installed by pip2 for python2.
So either have separate entry points for each pylint version, or modify this one manually to use the pylint package installed for python3.
i'm trying to port some Java Lucene code into pylucene (v 2.3.1). i'm
using the examples in
http://svn.apache.org/viewcvs.cgi/lucene/pylucene/trunk/samples/, and
most of pylucene seems to come into my python (ubuntu 12.04, pydev
2.6.0, eclipse 3.7.2) enviroment just fine. eg, i'm able execute
lucene.initVM() (showing JCC is in place) and to define a Porter
stemmer following the example taken from
.../samples/PorterStemmerAnalyzer.py via:
self.analyzer = PorterStemmerAnalyzer()
but when i try to create a new IndexWriter, it stumbles on the
last argument to its constructor:
self.writer = lucene.IndexWriter(self.store, self.analyzer, True, lucene.IndexWriter.MaxFieldLength.LIMITED)
i get this error:
AttributeError: type object 'IndexWriter' has no attribute 'MaxFieldLength'.
this is the error that has me stumped at the moment, but there are
several other hacks (from their version .../samples) i had also made
(but also worry about):
replace lucene.Version.LUCENE_CURRENT with lucene.LucenePackage
lucene.SimpleFSDirectory with lucene.MMapDirectory
in order to get this far.
http://lucene.apache.org/pylucene/features.html says "The PyLucene API
exposes all Java Lucene classes in a flat namespace in the PyLucene
module." this doesn't seem entirely right,
lucene.StopAnalyzer.ENGLISH_STOP_WORDS_SET is known to pydev while
lucene.ENGLISH_STOP_WORDS_SET is not.
so it seems i am getting part of/an old version of/...? pylucene
engaged correctly, but not all of it!? why might this be?
almost certainly the problem had to do with the most recent version of pylucene available as a .deb was 2.3.1 while pylucene is now at v. 3.6.1 !
making from the source distribution takes a bit of touch. the instructions from JohnW at
http://john.wesorick.com/2011/11/installing-pylucene-on-ubuntu-1110.html were helpful.
for what it's worth, here are the changes i wound up making, first to the JDK spec for linux2 in jcc/setup.py:
JDK = {
'darwin': JAVAHOME,
'ipod': '/usr/include/gcc',
'linux2': '/usr/lib/jvm/java-7-openjdk-amd64',
'sunos5': '/usr/jdk/instances/jdk1.6.0',
'win32': JAVAHOME,
'mingw32': JAVAHOME,
'freebsd7': '/usr/local/diablo-jdk1.6.0'
}
and then to the Makefile:
PREFIX_PYTHON=/usr
ANT=JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 /usr/bin/ant
PYTHON=$(PREFIX_PYTHON)/bin/python
JCC=$(PYTHON) -m jcc --shared
NUM_FILES=4
I used rikb's answer and it worked, but I had to change
'linux2': '/usr/lib/jvm/java-7-openjdk-amd64',
to...
'linux2': '/usr/lib/jvm/java-6-openjdk-amd64',
Since I'm using Java 6. It appears he is too, so perhaps he hasn't used that configuration on Linux.
Also note that if you copy and paste all or part rikb's block of stuff for the Makefile you will probably have trailing spaces on each line. Then the 'sudo make' step will fail, rather mysteriously, with a message like "make: execvp: /usr: Permission denied". This is because the trailing space after "PREFIX_PYTHON=/usr " caused make to try to execute the dir /usr.