jayvdb / flake8-putty Goto Github PK
View Code? Open in Web Editor NEWFlake8 plugin to control reporting per file and line
License: MIT License
Flake8 plugin to control reporting per file and line
License: MIT License
Implement PyCQA/pycodestyle#27 as part of this plugin.
Some people prefer to have rules at the top of the module source rather than in a config file.
This will at least make some parts of flake8-putty unnecessary, similar to spookylukey/flake8-respect-noqa#3
Should this plugin only support flake8 2.x and recommend that requests for similar functionality in flake8 3.x be requested as features for the main utility, at least until there is push back from the maintainers like there was in flake8 2.x.
IMHO it'd be nice to have a # flake8: disable=X000
pattern for every code without having to explicitly define them. The syntax is similar to pylint's, but another syntax would work as well.
flake8_putty is broken for pywikibot, likely due to a change in either flake8 or pep8/pycodestyle.
18:31:33 + tox -v
18:31:33 using tox.ini: /home/jenkins/workspace/tox-jessie/tox.ini
18:31:33 using tox-1.9.2 from /usr/local/lib/python2.7/dist-packages/tox/__init__.pyc
18:31:33 flake8 create: /home/jenkins/workspace/tox-jessie/.tox/flake8
18:31:33 /home/jenkins/workspace/tox-jessie/.tox$ /usr/bin/python -m virtualenv --setuptools --python /usr/bin/python2.7 flake8 >/home/jenkins/workspace/tox-jessie/.tox/flake8/log/flake8-0.log
18:31:36 flake8 installdeps: flake8, pyflakes >= 1.1, hacking, flake8-docstrings>=0.2.6, flake8-putty>=0.3.2, flake8-coding, flake8-future-import, flake8-string-format, flake8-import-order, flake8-tuple>=0.2.8, flake8-print>=2.0.1, git+https://github.com/jayvdb/flake8-mock@use-ascii-readme
18:31:36 /home/jenkins/workspace/tox-jessie$ /home/jenkins/workspace/tox-jessie/.tox/flake8/bin/pip install --process-dependency-links --pre flake8 pyflakes >= 1.1 hacking flake8-docstrings>=0.2.6 flake8-putty>=0.3.2 flake8-coding flake8-future-import flake8-string-format flake8-import-order flake8-tuple>=0.2.8 flake8-print>=2.0.1 git+https://github.com/jayvdb/flake8-mock@use-ascii-readme >/home/jenkins/workspace/tox-jessie/.tox/flake8/log/flake8-1.log
18:31:40 flake8 develop-inst: /home/jenkins/workspace/tox-jessie
18:31:40 /home/jenkins/workspace/tox-jessie$ /home/jenkins/workspace/tox-jessie/.tox/flake8/bin/pip install --process-dependency-links --pre -e /home/jenkins/workspace/tox-jessie >/home/jenkins/workspace/tox-jessie/.tox/flake8/log/flake8-2.log
18:31:42 flake8 runtests: PYTHONHASHSEED='646594070'
18:31:42 /home/jenkins/workspace/tox-jessie$ /home/jenkins/workspace/tox-jessie/.tox/flake8/bin/flake8 --version
18:31:42 Traceback (most recent call last):
18:31:42 File ".tox/flake8/bin/flake8", line 11, in <module>
18:31:42 sys.exit(main())
18:31:42 File "/home/jenkins/workspace/tox-jessie/.tox/flake8/local/lib/python2.7/site-packages/flake8/main/cli.py", line 16, in main
18:31:42 app.run(argv)
18:31:42 File "/home/jenkins/workspace/tox-jessie/.tox/flake8/local/lib/python2.7/site-packages/flake8/main/application.py", line 292, in run
18:31:42 self._run(argv)
18:31:42 File "/home/jenkins/workspace/tox-jessie/.tox/flake8/local/lib/python2.7/site-packages/flake8/main/application.py", line 278, in _run
18:31:42 self.initialize(argv)
18:31:42 File "/home/jenkins/workspace/tox-jessie/.tox/flake8/local/lib/python2.7/site-packages/flake8/main/application.py", line 269, in initialize
18:31:42 self.register_plugin_options()
18:31:42 File "/home/jenkins/workspace/tox-jessie/.tox/flake8/local/lib/python2.7/site-packages/flake8/main/application.py", line 149, in register_plugin_options
18:31:42 self.check_plugins.register_options(self.option_manager)
18:31:42 File "/home/jenkins/workspace/tox-jessie/.tox/flake8/local/lib/python2.7/site-packages/flake8/plugins/manager.py", line 378, in register_options
18:31:42 list(self.manager.map(call_register_options))
18:31:42 File "/home/jenkins/workspace/tox-jessie/.tox/flake8/local/lib/python2.7/site-packages/flake8/plugins/manager.py", line 252, in map
18:31:42 yield func(self.plugins[name], *args, **kwargs)
18:31:42 File "/home/jenkins/workspace/tox-jessie/.tox/flake8/local/lib/python2.7/site-packages/flake8/plugins/manager.py", line 348, in generated_function
18:31:42 return method(optmanager, *args, **kwargs)
18:31:42 File "/home/jenkins/workspace/tox-jessie/.tox/flake8/local/lib/python2.7/site-packages/flake8/plugins/manager.py", line 198, in register_options
18:31:42 add_options(optmanager)
18:31:42 File "/home/jenkins/workspace/tox-jessie/.tox/flake8/local/lib/python2.7/site-packages/flake8_putty/extension.py", line 118, in add_options
18:31:42 parser.config_options.append('putty-select')
18:31:42 AttributeError: 'OptionManager' object has no attribute 'config_options'
18:31:42 ERROR: InvocationError: '/home/jenkins/workspace/tox-jessie/.tox/flake8/bin/flake8 --version'
investigating...
Need Appveyor builds running the tests, and the tests probably need overhauling to use os.sep
.
While building a generic solution for #10 , I started investigating logical lines, as provided by pep8 . This is another special case of #4 . A logical line provides a tightest reasonable scope for the multi line regex to be constrained inside of, and it happens to be very efficient as pep8 already provides it.
The logical lines branch has working code and tests. The next step is to define selector semantics for this. Im currently using /.../l
for logical line regex.
As discussed on #3 , it would be useful to recognise pylint comments like
# pylint: disable=unused-variable
# pylint: disable=W0612
When there is a line continuation operator, any auto-ignore comments on the last continued line should apply to all lines. This is another example of the multi-line regex problem (#4). In this case, it is an implicit multi-line regex, and can be implemented only for auto-ignore comments, which may be easier than the more generic solution.
The reason is that comments can not appear after line continuation operator. The following is a SyntaxError:
if True \ # flake8: xxx
and False:
print('not reached')
So, it must be
if True \
and False: # flake8: xxx
print('not reached')
And that comment needs to apply to the previous line as well, in a predicable manner (strip all whitespace).
Currently a #
comment is only removed if it is one a separate line.
i.e. A rule like
tests/textlib_tests.py,/self.assert.*{{/ : +P103 # invalidly detected as {} format string
will add P103 # invalidly detected as {} format string
as one of the codes to ignore, instead of ignoring P103
.
The stripping needs to done in such as way that #
is possible in the regex.
To disable some pep257 checks for @property
methods I would like to match on that and ignore some stuff on the next line. Is this possible in some way? If not were should I look to implement this?
Here are the packages installed:
$ flake8 --version
2.6.2 (
pycodestyle: 2.0.0,
pyflakes: 1.2.3,
flake8-putty: 0.4.0,
flake8_quotes: 0.8.1,
mccabe: 0.5.2,
naming: 0.4.1
)
CPython 3.5.1 on Darwin
I'm calling flake8 like so:
flake8 --putty-auto-ignore example.py
Here is example.py
:
# pylint: disable=blacklisted-name
# flake8: disable=E302
import pdb
def baz(msg):
print(msg)
pdb.set_trace()
print('done')
def bar(msg):
baz(msg)
def foo(msg):
bar(msg)
foo('hai')
But I'm still seeing in the terminal, the output:
$ flake8 --putty-auto-ignore debugging.py
debugging.py:6:1: E302 expected 2 blank lines, found 1
debugging.py:11:1: E302 expected 2 blank lines, found 1
debugging.py:14:1: E302 expected 2 blank lines, found 1
Add ability to disable checks when the module does not include any code; e.g. empty __init__
modules.
The flake8 jobs (except on Python 3.2) are currently failing due to something determining there is a syntax error in tox.ini
Invalid requirement: 'flake8-import-order # hacking has a similar rule'
Traceback (most recent call last):
File "/home/travis/build/jayvdb/flake8-putty/.tox/v241/lib/python2.6/site-packages/pip/req/req_install.py", line 78, in __init__
req = Requirement(req)
File "/home/travis/build/jayvdb/flake8-putty/.tox/v241/lib/python2.6/site-packages/pip/_vendor/packaging/requirements.py", line 96, in __init__
requirement_string[e.loc:e.loc + 8]))
InvalidRequirement: Invalid requirement, parse error at "'# hackin'"
Also occurring in py27, https://travis-ci.org/jayvdb/flake8-putty/jobs/140301311
This is strange because the last successful build used pip 6.0.7 and tox 2.3.1, and the new error is reported by the same version.
The only obvious difference since the last successful build is that virtualenv was 15.0.1 but it is now 15.0.2
Installing virtualenv v13 fixes the problem, but installing 14.0.6 or 15.0.1 doesnt :/
When starting a porting project, often many rules fail only on the new platform, especially SyntaxError and undefined names.
Ideally this selector uses environment marker
https://www.python.org/dev/peps/pep-0496/
Probably simplest to rely on https://github.com/pypa/packaging/blob/master/packaging/markers.py for the implementation.
At #2 (comment) , I suggested an possible modification to the current approach for filenames without a directory separator. i.e.
test_*.py : T100
Currently it only matches file ./test_*.py
, and not ./*/test_*.py
.
Maybe it would be useful to allow it to match the filename in subdirectories also.
I'm probably doing something wrong, but I can't figure out what it is ๐
I'm using this in my config:
putty-ignore =
test_*.py : +D100,D101,D202
However I still get those messages, e.g.:
./tests/unit/misc/test_sessions.py:48:1: D101 Missing docstring in public class
I tried different variations (test_*
, tests/*/*/test_*.py
, etc.) but I didn't get any of those to work. Any idea why?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.