Better linting with config files
This commit is contained in:
parent
e878fc538d
commit
91e6f4c37d
8
.flake8
Normal file
8
.flake8
Normal file
@ -0,0 +1,8 @@
|
||||
[flake8]
|
||||
# E241: Multiple spaces after ,
|
||||
# E265: Block comment should start with '#'
|
||||
# F401: Unused import (checked by pylint)
|
||||
# E501: Line too long (checked by pylint)
|
||||
ignore=E241,E265,F401,E501
|
||||
max_complexity = 10
|
||||
exclude = appdirs.py
|
42
.pylintrc
Normal file
42
.pylintrc
Normal file
@ -0,0 +1,42 @@
|
||||
[MASTER]
|
||||
ignore=appdirs.py
|
||||
|
||||
[MESSAGES CONTROL]
|
||||
disable=no-self-use,
|
||||
super-on-old-class,
|
||||
old-style-class,
|
||||
abstract-class-little-used,
|
||||
bad-builtin,
|
||||
star-args,
|
||||
fixme,
|
||||
global-statement,
|
||||
no-init,
|
||||
locally-disabled,
|
||||
too-many-ancestors,
|
||||
too-few-public-methods,
|
||||
too-many-public-methods
|
||||
|
||||
[BASIC]
|
||||
module-rgx=[a-z_]*$
|
||||
const-rgx=[A-Za-z_][A-Za-z0-9_]{0,30}$
|
||||
method-rgx=[a-z_][A-Za-z0-9_]{2,30}$
|
||||
attr-rgx=[a-z_][a-z0-9_]{0,30}$
|
||||
argument-rgx=[a-z_][a-z0-9_]{0,30}$
|
||||
variable-rgx=[a-z_][a-z0-9_]{0,30}$
|
||||
class-attribute-rgx=[A-Za-z_][A-Za-z0-9_]{1,30}$
|
||||
inlinevar-rgx=[a-z_][a-z0-9_]*$
|
||||
bad-names=foo,bar,baz,tmp
|
||||
|
||||
[FORMAT]
|
||||
max-line-length=79
|
||||
ignore-long-lines=<?https?://
|
||||
|
||||
[VARIABLES]
|
||||
dummy-variables-rgx=_$
|
||||
|
||||
[CLASSES]
|
||||
defining-attr-methods=__init__,__new__,setUp
|
||||
|
||||
[DESIGN]
|
||||
max-args=10
|
||||
max-attributes=12
|
@ -72,7 +72,7 @@ class KeyParser(QObject):
|
||||
Return:
|
||||
True if event has been handled, False otherwise.
|
||||
"""
|
||||
MODMASK2STR = {
|
||||
modmask2str = {
|
||||
Qt.ControlModifier: 'Ctrl',
|
||||
Qt.AltModifier: 'Alt',
|
||||
Qt.MetaModifier: 'Meta',
|
||||
@ -86,7 +86,7 @@ class KeyParser(QObject):
|
||||
if not mod & (Qt.ControlModifier | Qt.AltModifier | Qt.MetaModifier):
|
||||
# won't be a shortcut with modifiers
|
||||
return False
|
||||
for (mask, s) in MODMASK2STR.items():
|
||||
for (mask, s) in modmask2str.items():
|
||||
if mod & mask:
|
||||
modstr += s + '+'
|
||||
keystr = QKeySequence(e.key()).toString()
|
||||
|
@ -26,7 +26,7 @@ from qutebrowser.commands.command import Command
|
||||
cmd_dict = {}
|
||||
|
||||
|
||||
class register:
|
||||
class register: # pylint: disable=invalid-name
|
||||
|
||||
"""Decorator to register a new command handler.
|
||||
|
||||
|
@ -242,8 +242,8 @@ class CompletionModel(QAbstractItemModel):
|
||||
item.setdata(index.column(), value, role)
|
||||
except (IndexError, ValueError):
|
||||
return False
|
||||
# We explicitely need to select this version, see [1].
|
||||
# [1] http://python.6.x6.nabble.com/Bug-Report-pyqt5-discard-silently-signal-with-missing-optional-parameters-dataChanged-roles-for-exam-tt5043737.html # pylint: disable=line-too-long
|
||||
# We explicitely need to select this version, see:
|
||||
# http://python.6.x6.nabble.com/Bug-Report-pyqt5-discard-silently-signal-with-missing-optional-parameters-dataChanged-roles-for-exam-tt5043737.html
|
||||
self.dataChanged.emit(index, index, [])
|
||||
return True
|
||||
|
||||
|
@ -70,7 +70,7 @@ class QuteSchemeHandler(SchemeHandler):
|
||||
"""
|
||||
return url.replace('http://', '').replace('qute:', 'qute_')
|
||||
|
||||
def createRequest(self, op, request, outgoingData):
|
||||
def createRequest(self, op, request, outgoing_data):
|
||||
"""Create a new request.
|
||||
|
||||
Args:
|
||||
@ -81,6 +81,7 @@ class QuteSchemeHandler(SchemeHandler):
|
||||
Return:
|
||||
A QNetworkReply.
|
||||
"""
|
||||
# pylint: disable=unused-argument
|
||||
# FIXME handle unknown pages
|
||||
# FIXME adjust URLutils based on handlers
|
||||
logging.debug('request: {}'.format(request))
|
||||
|
@ -28,7 +28,7 @@ class SchemeHandler(QObject):
|
||||
|
||||
"""Abstract base class for custom scheme handlers."""
|
||||
|
||||
def createRequest(self, op, request, outgoingData):
|
||||
def createRequest(self, op, request, outgoing_data):
|
||||
"""Create a new request.
|
||||
|
||||
Args:
|
||||
|
@ -35,7 +35,7 @@ class Style(QCommonStyle):
|
||||
Based on:
|
||||
|
||||
http://stackoverflow.com/a/17294081
|
||||
https://code.google.com/p/makehuman/source/browse/trunk/makehuman/lib/qtgui.py # pylint: disable=line-too-long
|
||||
https://code.google.com/p/makehuman/source/browse/trunk/makehuman/lib/qtgui.py
|
||||
|
||||
Attributes:
|
||||
_style: The base/"parent" style.
|
||||
|
@ -76,9 +76,9 @@ def _is_url_naive(url):
|
||||
Return:
|
||||
True if the url really is an URL, False otherwise.
|
||||
"""
|
||||
PROTOCOLS = ['http://', 'https://']
|
||||
protocols = ['http://', 'https://']
|
||||
u = urlstring(url)
|
||||
return (any(u.startswith(proto) for proto in PROTOCOLS) or '.' in u or
|
||||
return (any(u.startswith(proto) for proto in protocols) or '.' in u or
|
||||
u == 'localhost')
|
||||
|
||||
|
||||
|
@ -39,37 +39,6 @@ status = OrderedDict()
|
||||
options = {
|
||||
'target': 'qutebrowser',
|
||||
'disable': {
|
||||
'pylint': [
|
||||
# short variable names can be nice
|
||||
'invalid-name',
|
||||
# Basically unavoidable with Qt
|
||||
'too-many-public-methods',
|
||||
'no-self-use',
|
||||
# These don't even exist in python3
|
||||
'super-on-old-class',
|
||||
'old-style-class',
|
||||
# False-positives
|
||||
'abstract-class-little-used',
|
||||
# map/filter can be nicer than comprehensions
|
||||
'bad-builtin',
|
||||
# I disagree with these
|
||||
'star-args',
|
||||
'fixme',
|
||||
'too-many-instance-attributes',
|
||||
'global-statement',
|
||||
'no-init',
|
||||
'too-many-arguments',
|
||||
'too-few-public-methods',
|
||||
'too-many-ancestors',
|
||||
# visual noise
|
||||
'locally-disabled',
|
||||
],
|
||||
'flake8': [
|
||||
'E241', # Multiple spaces after ,
|
||||
'E265', # Block comment should start with '#'
|
||||
'F401', # Unused import (checked by pylint)
|
||||
'E501', # Line too long (checked by pylint)
|
||||
],
|
||||
'pep257': [
|
||||
'D102', # Docstring missing, will be handled by others
|
||||
'D209', # Blank line before closing """ (removed from PEP257)
|
||||
@ -77,8 +46,9 @@ options = {
|
||||
},
|
||||
'exclude': ['appdirs.py'],
|
||||
'other': {
|
||||
'pylint': ['--output-format=colorized', '--reports=no'],
|
||||
'flake8': ['--max-complexity=10'],
|
||||
'pylint': ['--output-format=colorized', '--reports=no',
|
||||
'--rcfile=.pylintrc'],
|
||||
'flake8': ['--max-complexity=10', '--config=.flake8'],
|
||||
},
|
||||
}
|
||||
|
||||
@ -164,14 +134,26 @@ def _get_args(checker):
|
||||
if checker == 'pylint':
|
||||
try:
|
||||
args += ['--disable=' + ','.join(options['disable']['pylint'])]
|
||||
except KeyError:
|
||||
pass
|
||||
try:
|
||||
args += ['--ignore=' + ','.join(options['exclude'])]
|
||||
except KeyError:
|
||||
pass
|
||||
try:
|
||||
args += options['other']['pylint']
|
||||
except KeyError:
|
||||
pass
|
||||
elif checker == 'flake8':
|
||||
try:
|
||||
args += ['--ignore=' + ','.join(options['disable']['flake8'])]
|
||||
except KeyError:
|
||||
pass
|
||||
try:
|
||||
args += ['--exclude=' + ','.join(options['exclude'])]
|
||||
except KeyError:
|
||||
pass
|
||||
try:
|
||||
args += options['other']['flake8']
|
||||
except KeyError:
|
||||
pass
|
||||
@ -179,8 +161,14 @@ def _get_args(checker):
|
||||
args = []
|
||||
try:
|
||||
args += ['--ignore=' + ','.join(options['disable']['pep257'])]
|
||||
except KeyError:
|
||||
pass
|
||||
try:
|
||||
args += ['--match=(?!{}).*\.py'.format('|'.join(
|
||||
options['exclude']))]
|
||||
except KeyError:
|
||||
pass
|
||||
try:
|
||||
args += options['other']['pep257']
|
||||
except KeyError:
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user