Module: check_mk
Branch: master
Commit: eca1b2156ebd9b021d9808e85e8723e57c9faeeb
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=eca1b2156ebd9b…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Wed Jul 4 11:02:51 2018 +0200
Fixed and enabled keyword-arg-before-vararg warnings.
Note that there was actually no way to pass "enabled" as a keyword argument
and pass extra positional arguments as well. So Profile.__init__'s
signature didn't make sense, but the fix was easy: Just remove positional
arguments. The same holds for ImageUpload.__init__.
CMKWebLogger.exception is a different story: Its signature differs from the
one of the superclass method, which is ugly and a design no-no. Rather than
fixing all the call sites, we introduce some local Kung Fu...
Change-Id: Ic9a09d40491ef224073056ca8192d2c10cdb8669
---
cmk/profile.py | 5 ++---
tests/pylint/pylintrc | 1 -
web/htdocs/log.py | 14 +++++++++++---
web/htdocs/valuespec.py | 4 ++--
4 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/cmk/profile.py b/cmk/profile.py
index 39e9918..062a03b 100644
--- a/cmk/profile.py
+++ b/cmk/profile.py
@@ -36,10 +36,9 @@ import cmk.log
class Profile(object):
- def __init__(self, enabled=True, profile_file=None, *args, **kwargs):
+ def __init__(self, enabled=True, profile_file=None, **kwargs):
self._enabled = enabled
self._profile_file = profile_file
- self._args = args
self._kwargs = kwargs
self._profile = None
@@ -47,7 +46,7 @@ class Profile(object):
def __enter__(self):
if self._enabled:
cmk.log.logger.info("Recording profile")
- self._profile = cProfile.Profile(*self._args, **self._kwargs)
+ self._profile = cProfile.Profile(**self._kwargs)
self._profile.enable()
return self
diff --git a/tests/pylint/pylintrc b/tests/pylint/pylintrc
index 7359868..0e5e51f 100644
--- a/tests/pylint/pylintrc
+++ b/tests/pylint/pylintrc
@@ -39,7 +39,6 @@ disable=
global-variable-undefined,
inconsistent-return-statements,
invalid-name,
- keyword-arg-before-vararg,
len-as-condition,
line-too-long,
logging-not-lazy,
diff --git a/web/htdocs/log.py b/web/htdocs/log.py
index 18a5ac9..ce21647 100644
--- a/web/htdocs/log.py
+++ b/web/htdocs/log.py
@@ -31,13 +31,21 @@ import cmk.log
import cmk.paths
class CMKWebLogger(_logging.getLoggerClass()):
- def exception(self, msg=None, *args, **kwargs):
+ def exception(self, *args, **kwargs):
"""Logs an optional message together with the traceback of the
last exception to the current logger (-> web.log)"""
- if msg is None:
+ # FIXME: Ugly Kung Fu to make the msg positional argument optional. This
+ # is a consequence of the cruel hack to change exceptions's signature,
+ # something which we shouldn't do: Either fix all the call sites or
+ # introduce another method.
+ if args:
+ msg = args[0]
+ args = args[1:]
+ else:
msg = _('Internal error')
+ msg = kwargs.pop('msg', msg)
- super(CMKWebLogger, self).exception("%s %s" % (html.request_uri(),
msg))
+ super(CMKWebLogger, self).exception("%s %s" % (html.request_uri(),
msg), *args, **kwargs)
_logging.setLoggerClass(CMKWebLogger)
diff --git a/web/htdocs/valuespec.py b/web/htdocs/valuespec.py
index c24d6e3..715320f 100644
--- a/web/htdocs/valuespec.py
+++ b/web/htdocs/valuespec.py
@@ -4026,10 +4026,10 @@ class FileUpload(ValueSpec):
class ImageUpload(FileUpload):
- def __init__(self, max_size=None, show_current_image=False, *args, **kwargs):
+ def __init__(self, max_size=None, show_current_image=False, **kwargs):
self._max_size = max_size
self._show_current_image = show_current_image
- FileUpload.__init__(self, *args, **kwargs)
+ FileUpload.__init__(self, **kwargs)
def render_input(self, varprefix, value):