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:
|
Return:
|
||||||
True if event has been handled, False otherwise.
|
True if event has been handled, False otherwise.
|
||||||
"""
|
"""
|
||||||
MODMASK2STR = {
|
modmask2str = {
|
||||||
Qt.ControlModifier: 'Ctrl',
|
Qt.ControlModifier: 'Ctrl',
|
||||||
Qt.AltModifier: 'Alt',
|
Qt.AltModifier: 'Alt',
|
||||||
Qt.MetaModifier: 'Meta',
|
Qt.MetaModifier: 'Meta',
|
||||||
@ -86,7 +86,7 @@ class KeyParser(QObject):
|
|||||||
if not mod & (Qt.ControlModifier | Qt.AltModifier | Qt.MetaModifier):
|
if not mod & (Qt.ControlModifier | Qt.AltModifier | Qt.MetaModifier):
|
||||||
# won't be a shortcut with modifiers
|
# won't be a shortcut with modifiers
|
||||||
return False
|
return False
|
||||||
for (mask, s) in MODMASK2STR.items():
|
for (mask, s) in modmask2str.items():
|
||||||
if mod & mask:
|
if mod & mask:
|
||||||
modstr += s + '+'
|
modstr += s + '+'
|
||||||
keystr = QKeySequence(e.key()).toString()
|
keystr = QKeySequence(e.key()).toString()
|
||||||
|
@ -26,7 +26,7 @@ from qutebrowser.commands.command import Command
|
|||||||
cmd_dict = {}
|
cmd_dict = {}
|
||||||
|
|
||||||
|
|
||||||
class register:
|
class register: # pylint: disable=invalid-name
|
||||||
|
|
||||||
"""Decorator to register a new command handler.
|
"""Decorator to register a new command handler.
|
||||||
|
|
||||||
|
@ -242,8 +242,8 @@ class CompletionModel(QAbstractItemModel):
|
|||||||
item.setdata(index.column(), value, role)
|
item.setdata(index.column(), value, role)
|
||||||
except (IndexError, ValueError):
|
except (IndexError, ValueError):
|
||||||
return False
|
return False
|
||||||
# We explicitely need to select this version, see [1].
|
# We explicitely need to select this version, see:
|
||||||
# [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
|
# 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, [])
|
self.dataChanged.emit(index, index, [])
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ class QuteSchemeHandler(SchemeHandler):
|
|||||||
"""
|
"""
|
||||||
return url.replace('http://', '').replace('qute:', 'qute_')
|
return url.replace('http://', '').replace('qute:', 'qute_')
|
||||||
|
|
||||||
def createRequest(self, op, request, outgoingData):
|
def createRequest(self, op, request, outgoing_data):
|
||||||
"""Create a new request.
|
"""Create a new request.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -81,6 +81,7 @@ class QuteSchemeHandler(SchemeHandler):
|
|||||||
Return:
|
Return:
|
||||||
A QNetworkReply.
|
A QNetworkReply.
|
||||||
"""
|
"""
|
||||||
|
# pylint: disable=unused-argument
|
||||||
# FIXME handle unknown pages
|
# FIXME handle unknown pages
|
||||||
# FIXME adjust URLutils based on handlers
|
# FIXME adjust URLutils based on handlers
|
||||||
logging.debug('request: {}'.format(request))
|
logging.debug('request: {}'.format(request))
|
||||||
|
@ -28,7 +28,7 @@ class SchemeHandler(QObject):
|
|||||||
|
|
||||||
"""Abstract base class for custom scheme handlers."""
|
"""Abstract base class for custom scheme handlers."""
|
||||||
|
|
||||||
def createRequest(self, op, request, outgoingData):
|
def createRequest(self, op, request, outgoing_data):
|
||||||
"""Create a new request.
|
"""Create a new request.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -35,7 +35,7 @@ class Style(QCommonStyle):
|
|||||||
Based on:
|
Based on:
|
||||||
|
|
||||||
http://stackoverflow.com/a/17294081
|
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:
|
Attributes:
|
||||||
_style: The base/"parent" style.
|
_style: The base/"parent" style.
|
||||||
|
@ -76,9 +76,9 @@ def _is_url_naive(url):
|
|||||||
Return:
|
Return:
|
||||||
True if the url really is an URL, False otherwise.
|
True if the url really is an URL, False otherwise.
|
||||||
"""
|
"""
|
||||||
PROTOCOLS = ['http://', 'https://']
|
protocols = ['http://', 'https://']
|
||||||
u = urlstring(url)
|
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')
|
u == 'localhost')
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,37 +39,6 @@ status = OrderedDict()
|
|||||||
options = {
|
options = {
|
||||||
'target': 'qutebrowser',
|
'target': 'qutebrowser',
|
||||||
'disable': {
|
'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': [
|
'pep257': [
|
||||||
'D102', # Docstring missing, will be handled by others
|
'D102', # Docstring missing, will be handled by others
|
||||||
'D209', # Blank line before closing """ (removed from PEP257)
|
'D209', # Blank line before closing """ (removed from PEP257)
|
||||||
@ -77,8 +46,9 @@ options = {
|
|||||||
},
|
},
|
||||||
'exclude': ['appdirs.py'],
|
'exclude': ['appdirs.py'],
|
||||||
'other': {
|
'other': {
|
||||||
'pylint': ['--output-format=colorized', '--reports=no'],
|
'pylint': ['--output-format=colorized', '--reports=no',
|
||||||
'flake8': ['--max-complexity=10'],
|
'--rcfile=.pylintrc'],
|
||||||
|
'flake8': ['--max-complexity=10', '--config=.flake8'],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,14 +134,26 @@ def _get_args(checker):
|
|||||||
if checker == 'pylint':
|
if checker == 'pylint':
|
||||||
try:
|
try:
|
||||||
args += ['--disable=' + ','.join(options['disable']['pylint'])]
|
args += ['--disable=' + ','.join(options['disable']['pylint'])]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
args += ['--ignore=' + ','.join(options['exclude'])]
|
args += ['--ignore=' + ','.join(options['exclude'])]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
args += options['other']['pylint']
|
args += options['other']['pylint']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
elif checker == 'flake8':
|
elif checker == 'flake8':
|
||||||
try:
|
try:
|
||||||
args += ['--ignore=' + ','.join(options['disable']['flake8'])]
|
args += ['--ignore=' + ','.join(options['disable']['flake8'])]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
args += ['--exclude=' + ','.join(options['exclude'])]
|
args += ['--exclude=' + ','.join(options['exclude'])]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
args += options['other']['flake8']
|
args += options['other']['flake8']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
@ -179,8 +161,14 @@ def _get_args(checker):
|
|||||||
args = []
|
args = []
|
||||||
try:
|
try:
|
||||||
args += ['--ignore=' + ','.join(options['disable']['pep257'])]
|
args += ['--ignore=' + ','.join(options['disable']['pep257'])]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
args += ['--match=(?!{}).*\.py'.format('|'.join(
|
args += ['--match=(?!{}).*\.py'.format('|'.join(
|
||||||
options['exclude']))]
|
options['exclude']))]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
args += options['other']['pep257']
|
args += options['other']['pep257']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user