Hi All --
I just pushed a commit [1] to the pep8 repo that contains what I hope is a
fix for the issues with pep8 / flake8 config files that arose from the way
that pep8 #368 was handled, e.g. [2] (I think, I'm getting 500 errors when
I try to few issues on the flake8 repo, but I'm hoping that is transient).
This led to flake8 2.4.0 pinning to pep8 < 1.6 in it's latest release [3].
I'm hoping that folks can test out there configurations and ways of running
flake8 / pep8 with various configuration files (user and project specific
configs) and please report any issues to me.
Thanks in advance!
[1]
https://github.com/jcrocholl/pep8/commit/435d1cbf995a659a82d1d4b42d25e34595…
[2] https://gitlab.com/pycqa/flake8/issues/35
[3] https://pypi.python.org/pypi/flake8/2.4.0
~ Ian Lee
I have a very large project with deeply nested hierarchies. To find the
root directory I use a source root walker and append the root directory to
sys.path. This way, I can easily import things in the project relative to
the root directory.
The problem is that pylint doesn't detect this, even though I have a method
which appends the path imported in the files where the path is used. So all
my imports are marked as F0401
<http://pylint-messages.wikidot.com/messages:f0401>: Unable to import.
Is there any way to avoid this error message by getting pylint to
understand sys.path?
The __init__.py that is imported in files that need imports relative to the
root directory:
import os
import sys
def find_repo_rootdir():
def __check_parent(topdir):
for _, _, files in os.walk(topdir):
if '.THIS_IS_ROOT' in files:
return topdir
else:
next_ = topdir.rsplit("/", 1)
if len(next_) == 2:
return __check_parent(next_[0])
else:
return None
return __check_parent(os.path.abspath(os.path.dirname(__file__)))
repo_root = find_repo_rootdir()
if repo_root is not None and repo_root not in sys.path:
sys.path.append(repo_root)
Hello,
I'm happy to announce the release of Pylint 1.4.2 and astroid 1.3.5.
The following changes were included in these releases:
For pylint:
* Don't require a docstring for empty modules. Closes issue #261.
* Fix a false positive with `too-few-format-args` string warning,
emitted when the string format contained a normal positional
argument ('{0}'), mixed with a positional argument which did
an attribute access ('{0.__class__}').
Closes issue #463.
* Take in account all the methods from the ancestors
when checking for too-few-public-methods. Closes issue #471.
* Catch enchant errors and emit 'invalid-characters-in-docstring'
when checking for spelling errors. Closes issue #469.
* Use all the inferred statements for the super-init-not-called
check. Closes issue #389.
* Add a new warning, 'unichr-builtin', emitted by the Python 3
porting checker, when the unichr builtin is found. Closes issue #472.
* Add a new warning, 'intern-builtin', emitted by the Python 3
porting checker, when the intern builtin is found. Closes issue #473.
* Add support for editable installations.
* The HTML output accepts the `--msg-template` option. Patch by
Dan Goldsmith.
* Add 'map-builtin-not-iterating' (replacing 'implicit-map-evaluation'),
'zip-builtin-not-iterating', 'range-builtin-not-iterating', and
'filter-builtin-not-iterating' which are emitted by `--py3k` when the
appropriate built-in is not used in an iterating context (semantics
taken from 2to3).
* Add a new warning, 'unidiomatic-typecheck', emitted when an explicit
typecheck uses type() instead of isinstance(). For example,
`type(x) == Y` instead of `isinstance(x, Y)`. Patch by Chris Rebert.
Closes issue #299.
* Add support for combining the Python 3 checker mode with the --jobs
flag (--py3k and --jobs). Closes issue #467.
* Add a new warning for the Python 3 porting checker, 'using-cmp-argument',
emitted when the `cmp` argument for the `list.sort` or `sorted builtin`
is encountered.
* Make the --py3k flag commutative with the -E flag. Also, this patch
fixes the leaks of error messages from the Python 3 checker when
the errors mode was activated. Closes issue #437.
For astroid:
* Add the ability to optimize small ast subtrees,
with the first use in the optimization of multiple
BinOp nodes. This removes recursivity in the rebuilder
when dealing with a lot of small strings joined by the
addition operator. Closes issue #59.
* Obtain the methods for the nose brain tip through an
unittest.TestCase instance. Closes Pylint issue #457.
* Fix a crash which occurred when a class was the ancestor
of itself. Closes issue #78.
* Improve the scope_lookup method for Classes regarding qualified
objects, with an attribute name exactly as one provided in the
class itself.
For example, a class containing an attribute 'first',
which was also an import and which had, as a base, a qualified name
or a Gettattr node, in the form 'module.first', then Pylint would
have inferred the `first` name as the function from the Class,
not the import. Closes Pylint issue #466.
* Implement the assigned_stmts operation for Starred nodes,
which was omitted when support for Python 3 was added in astroid.
Closes issue #36.
If you find any bugs, don't hesitate to open a new issue on our issue tracker.
Enjoy!
Dear Flake8ers,
I am trying to run flake8 programmatically in a Test class as follows:
import flake8.main
import nose.tools as nt
class TestCodeFormat(object):
def setUp(self):
self.files = find_py_files(os.path.dirname(mmfutils.__file__))
def test_flake8_conformance(self):
# Pass in the files here so that config setup.cfg file gets found
style_guide = flake8.main.get_style_guide(paths=self.files)
result = style_guide.check_files()
nt.eq_(result.total_errors, 0,
"Found {0} code style errors (and warnings)."
.format(result.total_errors))
The problem I am having is that there is no output when jobs > 1. This is probably something to do with stdout flushing and multiprocessing when running under nosetests.
Is there any solution that will allow parallel processing with displayed output. (I could change the error message to use result.messages or something, but don't see an easy way of properly formatting output with filenames and lines numbers etc.)
Thanks,
Michael.
P.S.
1) Please let me know if I should file an issue. I thought this might be resolved by #21 but even using the latest sources does not help.
2) flake8 and python setup.py flake8 both work fine, so another solution would be if I can somehow trigger this from "python setup.py nosetests" or "python setup.py test" but it seems to be something of a challenge to customize setup.py commands.
3) Setting nose's nocapture=1 also works, but the errors then are not deferred until the end of the tests and so can get lost.
Following the NIST recommendation:
"For each module, either limit cyclomatic complexity to [the agreed-upon limit] or provide a written explanation of why the limit was exceeded."
Is there a way of providing a "written explanation" for functions with one of
# pragma: max-complexity 15
# flake8: max-complexity 15
etc.?
Michael.
Hi,
flake8 2.3.0 warns me when a variable is never actually used, e.g.:
a = 1
It doesn't seem to check for unused multiple assigments, e.g.:
obj, created = RefutationResponse.objects.update_or_create(...)
--
Nik Nyby
Programmer
Columbia Center for New Media Teaching and Learning
nnyby(a)columbia.edu | (212) 854-7076