I've just started using flake8. I'm using 2.2.5 (pep8: 1.5.7, pyflakes:
0.8.1, mccabe: 0.3, flake8-debugger: 1.3.2) CPython 2.7.1 on Darwin
Config files don't seem to be being read in. I've tried defining it
(config.cfg) using --config, putting it in ., putting it in everything up
from ., and putting it in ~/.config/flake8. No matter what I try flake8
doesn't seem to be picking them up. Using --ignore works fine.
Here's my config file:
max-line-length = 200
# E251 unexpected spaces around keyword / parameter equals
# E711 comparison to None should be if cond is not None
# E501 line too long (203 > 200 characters)
# E303 too many blank lines (2)
# E712 comparison to True should be 'if cond is not True:' or 'if not cond:'
# E302 expected 2 blank lines, found 1
# E226 missing whitespace around arithmetic operator
# W291 trailing whitespace
# W293 blank line contains whitespace
# W391 blank line at end of file
# E111 indentation is not a multiple of four
# E702 multiple statements on one line (semicolon)
ignore = E251,E711,E501,E303,E712,E302,E226,W291,W293,W391,E111,E702,E265
Jason Killen jsnklln(a)gmail.com
Pain is inevitable, misery is optional.
I'm implementing pylint plugin for web2py: it executes user code in a
special environment populated with predefined objects.
My transformer adds imports for pylint not to complain about undefined
But after that pylint complains about unused-wildcard-import.
Is there any way to suppress some messages or at least to add some
'#pylint: disable=...' line to module from the transformer?
Thanks in advance, Alex
Pylint runs for several minutes on my project; I'd like to add it to my CI
build, but I'm not sure I want to introduce that much delay.
Is there any trick to optimizing it? Are there some particularly slow
inspections that I could disable?
I was working with Joe Gordon (who's subscribed to this list) and we
realized there's a very real desire for the ability to register a
check but not have it turned on by default. Thanks to some free time
today, I've been able to throw together an example of what that would
look like in flake8: https://gitlab.com/pycqa/flake8/merge_requests/14
I'm mainly looking for community and user based feedback. Are there
objections to a feature like this? Are there pitfalls? The approach is
a bit hack-ish, granted, but I doubt this is something pep8 has any
need to absorb.
I have a checker name webapp.py in my current directory. When I used pylint with param —load-plugins webapp, i got an errer like this:
Traceback (most recent call last):
File "/usr/local/bin/pylint", line 11, in <module>
File "/Library/Python/2.7/site-packages/pylint/__init__.py", line 23, in run_pylint
File "/Library/Python/2.7/site-packages/pylint/lint.py", line 1193, in __init__
File "/Library/Python/2.7/site-packages/pylint/lint.py", line 469, in load_plugin_modules
module = load_module_from_name(modname)
File "/Library/Python/2.7/site-packages/astroid/modutils.py", line 135, in load_module_from_name
return load_module_from_modpath(dotted_name.split('.'), path, use_sys)
File "/Library/Python/2.7/site-packages/astroid/modutils.py", line 178, in load_module_from_modpath
mp_file, mp_filename, mp_desc = imp.find_module(part, path)
ImportError: No module named webapp
first line is variable part, path in the method astroid.modutils.load_module_from_modpath
Then I changed the method pylint.lint.load_plugin_modules like this and it well works well.
My pylint version is 1.4.0 and astroid version is 1.3.2, os is Mac 10.10. Maybe it’s a bug need to fixed.
江哲 developer of
Pretend I have classes:
The MRO linearizations are:
L(object) = [object]
L(A) = [A, object]
L(B) = [B, object]
L(C) = [C, A, B, object]
L(D) = [D, object]
I'll say that L(X) > L(Y) if every
c in L(Y) occurs in L(X). By that rule
L(C) and L(D) are maximal linearizations.
I want to write an analysis which would
work best if I could gather up all the
linearization of all classes in a possibly
large package distributed over possibly
many files and find only
the maximal linearizations.
This is really a kind of whole-program analysis.
I don't believe that this fits the pylint model
very well, since it is reasonable to expect that
pylint would be run separately on each individual
file in a library.
Are there other analyses around that make use of
astroid and are more whole-program like?
flake8 has the doctests option that enables doctest checking.
Unfortunately it's global.
In objgraph I have a file (objgraph.py) where the doctest syntax is used
for examples, and another file (tests.py) where doctests are used for
actual test code.
If I set doctests = yes, I get false positives on objgraph.py about all
the undefined names in my examples.
If I set doctests = no, I get a false positive about 'import gc' in
test.py being unused, despite gc.collect() being called in many doctests.
Also, the code in my doctests doesn't get checked.
Do you think it would make sense to be able to enable/disable doctest
checking per file? I'm thinking either directives inside the files
# flake8: +doctests
# flake8: -doctests
or perhaps a list of glob patterns in setup.cfg, e.g.
doctests = tests.py
(while keeping support for the boolean values, of course)
We have enough youth, how about a fountain of SMART?
I think that making contents of proposed extensions subdirectory a separate
package from pylint itself would be a great convenience for users who may
not be ready to update to most recent version of pylint, but are interested
in some optional checker.
Please let me know what you think.
i actually writing a test case who check code style with flake8
i interested in retrieve only the name of the files with errors not the
error itself, so after some research i trying to capture the stdout of
flake8 and write the next code
out, err = sys.stdout, sys.stderr
dummy = StringIO()
sys.stdout, sys.stderr = dummy, dummy
pep8 = engine.get_style_guide()
pep8.paths = [....]
report = pep8.check_files()
sys.stdout, sys.stderr = out, err
Always dummy.getvalue() comes empty. Its another way to retrieve the list
of files who fail the check?
also i try to write my own report class who inherit from BaseQReport and
add redefining a error method with a multiprocessing.Queue for
communication but don't work
Sorry for my poor english grammar
Juan B Cabral