From 74898b1ed7370f7db2b993ecf3c3779ecde9dae2 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Tue, 19 Jan 2021 19:28:29 +0100 Subject: [PATCH] pylint --- src/rougail/annotator/__init__.py | 2 +- src/rougail/annotator/check.py | 4 ++-- src/rougail/annotator/condition.py | 4 ++-- src/rougail/annotator/family.py | 2 +- src/rougail/annotator/service.py | 2 +- src/rougail/annotator/variable.py | 3 +-- src/rougail/objspace.py | 6 +++--- src/rougail/path.py | 2 +- src/rougail/template.py | 10 +++++----- src/rougail/tiramisureflector.py | 6 +++--- src/rougail/xmlreflector.py | 2 +- 11 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/rougail/annotator/__init__.py b/src/rougail/annotator/__init__.py index c6bac217..41a08860 100644 --- a/src/rougail/annotator/__init__.py +++ b/src/rougail/annotator/__init__.py @@ -9,7 +9,7 @@ from .fill import FillAnnotator from .family import FamilyAnnotator, modes from .property import PropertyAnnotator -class SpaceAnnotator: +class SpaceAnnotator: # pylint: disable=R0903 """Transformations applied on a CreoleObjSpace instance """ def __init__(self, objectspace, eosfunc_file): diff --git a/src/rougail/annotator/check.py b/src/rougail/annotator/check.py index 8ec0d6dd..e12d9dfd 100644 --- a/src/rougail/annotator/check.py +++ b/src/rougail/annotator/check.py @@ -28,7 +28,7 @@ class CheckAnnotator: self.check_change_warning() self.convert_check() - def check_check(self): + def check_check(self): # pylint: disable=R0912 """valid and manage """ remove_indexes = [] @@ -46,7 +46,7 @@ class CheckAnnotator: xmlfiles = self.objectspace.display_xmlfiles(check.xmlfiles) msg = _(f'the target "{check.target}" in check cannot be a dynamic ' f'variable in {xmlfiles}') - raise DictConsistencyError(msg, 22) + raise DictConsistencyError(msg, 22) from err raise err check.is_in_leadership = self.objectspace.paths.is_in_leadership(check_name) if not hasattr(check, 'param'): diff --git a/src/rougail/annotator/condition.py b/src/rougail/annotator/condition.py index 261b3920..85d328bd 100644 --- a/src/rougail/annotator/condition.py +++ b/src/rougail/annotator/condition.py @@ -103,7 +103,7 @@ class Conditionnnotator: if not target.optional: xmlfiles = self.objectspace.display_xmlfiles(condition.xmlfiles) msg = f'cannot found target "{target.name}" in the condition in {xmlfiles}' - raise DictConsistencyError(_(msg), 12) + raise DictConsistencyError(_(msg), 12) from err remove_targets.append(index) remove_targets.sort(reverse=True) for index in remove_targets: @@ -209,7 +209,7 @@ class Conditionnnotator: xmlfiles = self.objectspace.display_xmlfiles(condition.xmlfiles) msg = _(f'the source "{condition.source}" in condition cannot be a dynamic ' f'variable in {xmlfiles}') - raise DictConsistencyError(msg, 20) + raise DictConsistencyError(msg, 20) from err def check_choice_option_condition(self): """remove condition for ChoiceOption that don't have param diff --git a/src/rougail/annotator/family.py b/src/rougail/annotator/family.py index d60cb950..0ca3c31d 100644 --- a/src/rougail/annotator/family.py +++ b/src/rougail/annotator/family.py @@ -8,7 +8,7 @@ from ..error import DictConsistencyError modes_level = ('basic', 'normal', 'expert') -class Mode: +class Mode: # pylint: disable=R0903 """Class to manage mode level """ def __init__(self, diff --git a/src/rougail/annotator/service.py b/src/rougail/annotator/service.py index 04b2e06a..2ebe9a15 100644 --- a/src/rougail/annotator/service.py +++ b/src/rougail/annotator/service.py @@ -177,7 +177,7 @@ class ServiceAnnotator: value, xmlfiles, path, - ): + ): # pylint: disable=R0913 variable = self.objectspace.variable(xmlfiles) variable.name = normalize_family(key) variable.mode = None diff --git a/src/rougail/annotator/variable.py b/src/rougail/annotator/variable.py index bd23ec6d..21e317d0 100644 --- a/src/rougail/annotator/variable.py +++ b/src/rougail/annotator/variable.py @@ -1,7 +1,6 @@ """Annotate variable """ from ..utils import normalize_family -from ..config import Config CONVERT_OPTION = {'number': dict(opttype="IntOption", func=int), @@ -44,7 +43,7 @@ FORCE_CHOICE = {'schedule': ['none', 'daily', 'weekly', 'monthly'], RENAME_ATTIBUTES = {'description': 'doc'} -class VariableAnnotator: +class VariableAnnotator: # pylint: disable=R0903 """Annotate variable """ def __init__(self, diff --git a/src/rougail/objspace.py b/src/rougail/objspace.py index 6f1b38e0..3673c991 100644 --- a/src/rougail/objspace.py +++ b/src/rougail/objspace.py @@ -149,7 +149,7 @@ class RougailObjSpace: redefine_variables, ) - def _xml_parse(self, + def _xml_parse(self, # pylint: disable=R0913 xmlfile, document, space, @@ -211,7 +211,7 @@ class RougailObjSpace: space, namespace, redefine_variables, - ): + ): # pylint: disable=R0913 """ retrieves or creates Rougail Object Subspace objects """ @@ -256,7 +256,7 @@ class RougailObjSpace: name, namespace, redefine_variables, - ): + ): # pylint: disable=R0913 """A redefinable object could be created or updated """ existed_var = self.get_existed_obj(name, diff --git a/src/rougail/path.py b/src/rougail/path.py index 641be0c9..d3e8fe50 100644 --- a/src/rougail/path.py +++ b/src/rougail/path.py @@ -110,7 +110,7 @@ class Path: return leadership.variable[0].path == path # Variable - def add_variable(self, + def add_variable(self, # pylint: disable=R0913 namespace: str, name: str, family: str, diff --git a/src/rougail/template.py b/src/rougail/template.py index 3238ac3f..03b6ffc8 100644 --- a/src/rougail/template.py +++ b/src/rougail/template.py @@ -44,12 +44,12 @@ def cl_compile(kls, *args, **kwargs): 'commentEndToken' : 'µ' * 10, 'multiLineCommentStartToken' : 'µ' * 10, 'multiLineCommentEndToken' : 'µ' * 10} - return kls.old_compile(*args, **kwargs) + return kls.old_compile(*args, **kwargs) # pylint: disable=E1101 ChtTemplate.old_compile = ChtTemplate.compile ChtTemplate.compile = cl_compile -class CheetahTemplate(ChtTemplate): +class CheetahTemplate(ChtTemplate): # pylint: disable=W0223 """Construct a cheetah templating object """ def __init__(self, @@ -200,7 +200,7 @@ class CreoleExtra: class CreoleTemplateEngine: """Engine to process Creole cheetah template """ - def __init__(self, + def __init__(self, # pylint: disable=R0913 config: Config, eosfunc_file: str, distrib_dir: str, @@ -278,10 +278,10 @@ class CreoleTemplateEngine: except CheetahNotFound as err: # pragma: no cover varname = err.args[0][13:-1] msg = f"Error: unknown variable used in template {source} to {destfilename}: {varname}" - raise TemplateError(_(msg)) + raise TemplateError(_(msg)) from err except Exception as err: # pragma: no cover msg = _(f"Error while instantiating template {source} to {destfilename}: {err}") - raise TemplateError(msg) + raise TemplateError(msg) from err with open(destfilename, 'w') as file_h: file_h.write(data) diff --git a/src/rougail/tiramisureflector.py b/src/rougail/tiramisureflector.py index 85fa2bd4..0b9962e0 100644 --- a/src/rougail/tiramisureflector.py +++ b/src/rougail/tiramisureflector.py @@ -11,7 +11,7 @@ FORCE_INFORMATIONS = ['help', 'test', 'manage'] ATTRIBUTES_ORDER = ('name', 'doc', 'default', 'multi') -class Root(): +class Root(): # pylint: disable=R0903 """Root classes """ path = '.' @@ -57,7 +57,7 @@ class TiramisuReflector: elt, ) # parse object - baseelt.reflector_object.get() + baseelt.reflector_object.get() # pylint: disable=E1101 @staticmethod def reorder_family(space): @@ -162,7 +162,7 @@ class TiramisuReflector: return '\n'.join(self.text) -class BaseElt: +class BaseElt: # pylint: disable=R0903 """Base element """ name = 'baseoption' diff --git a/src/rougail/xmlreflector.py b/src/rougail/xmlreflector.py index 0e366a7d..db38dc10 100644 --- a/src/rougail/xmlreflector.py +++ b/src/rougail/xmlreflector.py @@ -38,7 +38,7 @@ class XMLReflector: try: document = parse(xmlfile) except XMLSyntaxError as err: - raise DictConsistencyError(_(f'{xmlfile} is not an XML file: {err}'), 52) + raise DictConsistencyError(_(f'{xmlfile} is not an XML file: {err}'), 52) from err if not self.dtd.validate(document): dtd_error = self.dtd.error_log.filter_from_errors()[0] msg = _(f'"{xmlfile}" not a valid XML file: {dtd_error}')