Commit a6ec5483 authored by Thanassis Tsiodras's avatar Thanassis Tsiodras

Addressing pylint reports.

parent 3dbf614e
......@@ -213,7 +213,7 @@ class SynchronousToolGlueGeneratorGeneric(Generic[TSource, TDestin]):
self.CleanNameAsADAWants(subProgram._id + "_" + subProgramImplementation),
self.CleanNameAsADAWants(param._id))
srcVar = self.SourceVar(nodeTypename, encoding, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
srcVar = self.SourceVar(nodeTypename, encoding, node, subProgram, subProgramImplementation, param, leafTypeDict, names) # pylint: disable=assignment-from-no-return
if subProgramImplementation == "QGenAda":
self.ADA_HeaderFile.write(
......@@ -224,7 +224,7 @@ class SynchronousToolGlueGeneratorGeneric(Generic[TSource, TDestin]):
(tmpSpName, self.CleanNameAsToolWants(nodeTypename), "asn1Scc" + self.CleanNameAsToolWants(nodeTypename)))
self.ADA_SourceFile.write('begin\n')
toolToAsn1 = self.FromToolToASN1SCC()
toolToAsn1 = self.FromToolToASN1SCC() # pylint: disable=assignment-from-no-return
lines = toolToAsn1.Map(
"QGen_OUT",
"T_OUT",
......@@ -276,9 +276,9 @@ class SynchronousToolGlueGeneratorGeneric(Generic[TSource, TDestin]):
# Write the mapping code for the message
if self.useOSS and encoding.lower() == "uper":
toolToAsn1 = self.FromToolToOSS()
toolToAsn1 = self.FromToolToOSS() # pylint: disable=assignment-from-no-return
else:
toolToAsn1 = self.FromToolToASN1SCC()
toolToAsn1 = self.FromToolToASN1SCC() # pylint: disable=assignment-from-no-return
lines = toolToAsn1.Map(
srcVar,
"var_" + self.CleanNameAsToolWants(nodeTypename),
......@@ -345,7 +345,7 @@ class SynchronousToolGlueGeneratorGeneric(Generic[TSource, TDestin]):
self.CleanNameAsADAWants(subProgram._id + "_" + subProgramImplementation),
param._id)
targetVar = self.TargetVar(nodeTypename, encoding, node, subProgram, subProgramImplementation, param, leafTypeDict, names)
targetVar = self.TargetVar(nodeTypename, encoding, node, subProgram, subProgramImplementation, param, leafTypeDict, names) # pylint: disable=assignment-from-no-return
if subProgramImplementation == "QGenAda":
self.ADA_HeaderFile.write(
......@@ -356,7 +356,7 @@ class SynchronousToolGlueGeneratorGeneric(Generic[TSource, TDestin]):
(tmpSpName, "asn1Scc" + self.CleanNameAsToolWants(nodeTypename), self.CleanNameAsToolWants(nodeTypename)))
self.ADA_SourceFile.write(' begin\n')
asn1ToTool = self.FromASN1SCCtoTool()
asn1ToTool = self.FromASN1SCCtoTool() # pylint: disable=assignment-from-no-return
lines = asn1ToTool.Map(
"T_IN",
"QGen_IN",
......@@ -422,7 +422,7 @@ class SynchronousToolGlueGeneratorGeneric(Generic[TSource, TDestin]):
self.CleanNameAsToolWants(nodeTypename)))
if self.useOSS and encoding.lower() == "uper":
asn1ToTool = self.FromOSStoTool()
asn1ToTool = self.FromOSStoTool() # pylint: disable=assignment-from-no-return
lines = asn1ToTool.Map(
"(*pVar_" + self.CleanNameAsToolWants(nodeTypename) + ")",
targetVar,
......@@ -430,7 +430,7 @@ class SynchronousToolGlueGeneratorGeneric(Generic[TSource, TDestin]):
leafTypeDict,
names) if asn1ToTool else []
else:
asn1ToTool = self.FromASN1SCCtoTool()
asn1ToTool = self.FromASN1SCCtoTool() # pylint: disable=assignment-from-no-return
lines = asn1ToTool.Map(
"var_" + self.CleanNameAsToolWants(nodeTypename),
targetVar,
......@@ -555,7 +555,7 @@ class SynchronousToolGlueGeneratorGeneric(Generic[TSource, TDestin]):
encoding.lower(),
self.CleanNameAsADAWants(sp._id + "_" + subProgramImplementation),
param._id)
if isinstance(param, InOutParam) or isinstance(param, OutParam):
if isinstance(param, (InOutParam, OutParam)): # pylint: disable=assignment-from-no-return
self.ADA_SourceFile.write(
' %s(QGen_%s, %s.all);\n' % (
tmpSpName,
......@@ -645,7 +645,7 @@ class SynchronousToolGlueGeneratorGeneric(Generic[TSource, TDestin]):
encoding.lower(),
self.CleanNameAsADAWants(sp._id + "_" + subProgramImplementation),
param._id)
if isinstance(param, InOutParam) or isinstance(param, OutParam):
if isinstance(param, (InOutParam, OutParam)):
self.C_SourceFile.write(' *pSize_%s = %s(p%s, %s);\n' %
(self.CleanNameAsToolWants(param._id),
tmpSpName,
......
......@@ -80,7 +80,7 @@ but with an extra call to OnFinal at the end.
import os
import sys
import distutils.spawn as spawn
from distutils import spawn
from typing import cast, Optional, Dict, List, Tuple, Set, Any # NOQA pylint: disable=unused-import
......@@ -301,7 +301,7 @@ def ProcessAsync( # pylint: disable=dangerous-default-value
maybeFVname: str,
useOSS: bool,
badTypes: SetOfBadTypenames,
loaded_languages_cache: List[str]=[]) -> Async_B_Mapper: # pylint: disable=invalid-sequence-index
loaded_languages_cache: List[str] = []) -> Async_B_Mapper: # pylint: disable=invalid-sequence-index
backend = getAsyncBackend(modelingLanguage)
......@@ -390,7 +390,7 @@ def ProcessCustomBackends(
# We do, start the work
spName, sp_impl, lang, maybeFVname = si[0], si[1], si[2], si[3]
sp = commonPy.aadlAST.g_apLevelContainers[spName]
if len(sp._params) == 0:
if not sp._params:
if lang.lower() == "gui_ri": # pragma: no cover
if "gui_polling" not in sp._id: # pragma: no cover
panic("Due to wxWidgets limitations, your TCs must have at least one parameter (fix %s)" % sp._id) # pragma: no cover
......@@ -500,7 +500,7 @@ def main() -> None:
if len(asn1files) == 1:
asnFile = asn1files[0]
commonPy.asnParser.ParseAsnFileList(asn1files)
elif len(asn1files) != 0:
elif asn1files:
panic("There appear to be more than one ASN.1 files referenced (%s)..." % str(asn1files))
if asnFile is not None:
......@@ -547,8 +547,8 @@ def main() -> None:
sp = commonPy.aadlAST.g_apLevelContainers[spName]
inform("Creating glue for parameters of %s.%s...", sp._id, sp_impl)
# Avoid generating empty glue - no parameters for this APLC
if len(sp._params) == 0:
if not sp._params:
# Avoid generating empty glue - no parameters for this APLC
continue
# All SCADE versions are handled by lustre_B_mapper
......@@ -573,9 +573,4 @@ def main() -> None:
if __name__ == "__main__":
if "-pdb" in sys.argv:
sys.argv.remove("-pdb") # pragma: no cover
import pdb # pragma: no cover pylint: disable=wrong-import-position,wrong-import-order
pdb.run('main()') # pragma: no cover
else:
main()
main()
......@@ -228,9 +228,4 @@ def main() -> None:
if __name__ == "__main__":
if "-pdb" in sys.argv:
sys.argv.remove("-pdb") # pragma: no cover
import pdb # pragma: no cover pylint: disable=wrong-import-position,wrong-import-order
pdb.run('main()') # pragma: no cover
else:
main()
main()
......@@ -145,7 +145,7 @@ Members:
self._leafType = "BOOLEAN"
self._lineno = args.get('lineno', None)
self._bDefaultValue = args.get('bDefaultValue', None)
for i in args.keys():
for i in args:
assert i in AsnBool.validOptions
def __repr__(self) -> str:
......@@ -178,7 +178,7 @@ Members:
self._lineno = args.get('lineno', None)
self._range = args.get('range', [])
self._iDefaultValue = args.get('iDefaultValue', None)
for i in args.keys():
for i in args:
assert i in AsnInt.validOptions
def __repr__(self) -> str:
......@@ -224,7 +224,7 @@ Members:
self._baseRange = args.get('base', None)
self._exponentRange = args.get('exponent', None)
self._dbDefaultValue = args.get('defaultValue', None)
for i in args.keys():
for i in args:
assert i in AsnReal.validOptions
def __repr__(self) -> str:
......@@ -274,7 +274,7 @@ Members:
# nameless string types can't be used, so a unique pseudo-type name
# is created from the fieldname + "_type"
self._pseudoname = None # type: Union[None, str]
for i in args.keys():
for i in args:
assert i in AsnString.validOptions
def __repr__(self) -> str:
......@@ -387,7 +387,7 @@ Members:
# nameless string types can't be used, so a unique pseudo-type name
# is created from the fieldname + "_type"
self._pseudoname = None # type: Union[None, str]
for i in args.keys():
for i in args:
assert i in AsnEnumerated.validOptions
existing = {} # type: Dict[str, int]
for elem in self._members:
......@@ -472,7 +472,7 @@ Members:
self._leafType = "SEQUENCE"
self._members = args.get('members', [])
self._lineno = args.get('lineno', None)
for i in args.keys():
for i in args:
assert i in AsnSequence.validOptions
existing = {} # type: Dict[str, int]
for elem in self._members:
......@@ -513,7 +513,7 @@ class AsnSet(AsnComplexNode):
self._leafType = "SET"
self._members = args.get('members', [])
self._lineno = args.get('lineno', None)
for i in args.keys():
for i in args:
assert i in AsnSequence.validOptions
existing = {} # type: Dict[str, int]
for elem in self._members:
......@@ -563,7 +563,7 @@ Members:
self._leafType = "CHOICE"
self._members = args.get('members', [])
self._lineno = args.get('lineno', None)
for i in args.keys():
for i in args:
assert i in AsnChoice.validOptions
existing = {} # type: Dict[str, int]
for elem in self._members:
......@@ -642,7 +642,7 @@ Members:
self._lineno = args.get('lineno', None)
self._name = "unnamed" # default in case of SEQUENCE_OF SEQUENCE_OF
self._leafType = "SEQUENCEOF"
for i in args.keys():
for i in args:
assert i in AsnSequenceOf.validOptions
def __repr__(self) -> str:
......@@ -675,7 +675,7 @@ class AsnSetOf(AsnComplexNode):
self._lineno = args.get('lineno', None)
self._name = "unnamed" # default in case of SEQUENCE_OF SEQUENCE_OF
self._leafType = "SETOF"
for i in args.keys():
for i in args:
assert i in AsnSequenceOf.validOptions
def __repr__(self) -> str:
......@@ -715,7 +715,7 @@ Members:
self._lineno = args.get('lineno', None)
self._Min = args.get('Min', None)
self._Max = args.get('Max', None)
for i in args.keys():
for i in args:
assert i in AsnMetaMember.validOptions
def __repr__(self) -> str:
......@@ -747,7 +747,7 @@ e.g.:
self._lineno = args.get('lineno', None)
self._Min = args.get('Min', None)
self._Max = args.get('Max', None)
for i in args.keys():
for i in args:
assert i in AsnMetaType.validOptions
def __repr__(self) -> str:
......
......@@ -326,7 +326,7 @@ def ConvertCatalogueToASN_AST(
for inputSmp2File in inputSmp2Files:
a = etree.parse(open(inputSmp2File)) # type: Any # mypy bugs in ElementTree handling
root = a.getroot()
if len(root) < 1 or not root.tag.endswith('Catalogue'):
if len(root) < 1 or not root.tag.endswith('Catalogue'): # pylint: disable=len-as-condition
panic('', "You must use an XML file that contains an SMP2 Catalogue") # pragma: no cover
for t in root.xpath("//Type"):
a = Attributes(t)
......@@ -342,7 +342,7 @@ def ConvertCatalogueToASN_AST(
for inputSmp2File in inputSmp2Files:
a = etree.parse(open(inputSmp2File))
root = a.getroot()
if len(root) < 1 or not root.tag.endswith('Catalogue'):
if len(root) < 1 or not root.tag.endswith('Catalogue'): # pylint: disable=len-as-condition
panic('', "You must use an XML file that contains an SMP2 Catalogue") # pragma: no cover
for t in root.xpath("//Type"):
# Find the enclosing Namespace element
......
......@@ -77,14 +77,14 @@ def panicWithCallStack(msg: str) -> NoReturn:
def lcfirst(word: str) -> str:
if len(word):
if word:
return word[:1].lower() + word[1:]
else:
return word
def ucfirst(word: str) -> str:
if len(word):
if word:
return word[:1].upper() + word[1:]
else:
return word
......@@ -110,7 +110,7 @@ def readContexts(tapNumbers: str) -> Dict[str, str]:
class Matcher:
def __init__(self, pattern: str, flags: Any=0) -> None:
def __init__(self, pattern: str, flags: Any = 0) -> None:
self._pattern = re.compile(pattern, flags)
self._lastOne = None # type: Union[str, None]
self._match = None # type: Union[Match, None]
......
......@@ -42,7 +42,7 @@ from .commonPy.commonSMP2 import (
DashUnderscoreAgnosticDict, ConvertCatalogueToASN_AST)
def usage(coloredMsg: str="") -> None:
def usage(coloredMsg: str = "") -> None:
'''Prints help message and aborts. '''
usageMsg = 'Usage: smp2asn <options> <smp2Catalogues...>\n\n' \
'Where options must include:\n' \
......
......@@ -60,10 +60,9 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=coerce-method,nonzero-method,buffer-builtin,unichr-builtin,reload-builtin,using-cmp-argument,reduce-builtin,filter-builtin-not-iterating,zip-builtin-not-iterating,raising-string,long-builtin,backtick,long-suffix,delslice-method,suppressed-message,cmp-method,old-octal-literal,basestring-builtin,metaclass-assignment,print-statement,execfile-builtin,round-builtin,oct-method,standarderror-builtin,hex-method,import-star-module-level,indexing-exception,map-builtin-not-iterating,old-ne-operator,setslice-method,input-builtin,apply-builtin,range-builtin-not-iterating,xrange-builtin,parameter-unpacking,no-absolute-import,old-raise-syntax,dict-iter-method,unicode-builtin,unpacking-in-except,old-division,file-builtin,next-method-called,useless-suppression,raw_input-builtin,intern-builtin,getslice-method,dict-view-method,cmp-builtin,coerce-builtin,line-too-long,missing-docstring,protected-access,global-statement,too-many-arguments,too-many-branches,too-many-locals,bare-except,invalid-name,too-many-statements,broad-except,too-many-instance-attributes,too-many-public-methods,too-few-public-methods,similarities
disable=coerce-method,nonzero-method,buffer-builtin,unichr-builtin,reload-builtin,using-cmp-argument,reduce-builtin,filter-builtin-not-iterating,zip-builtin-not-iterating,raising-string,long-builtin,backtick,long-suffix,delslice-method,suppressed-message,cmp-method,old-octal-literal,basestring-builtin,metaclass-assignment,print-statement,execfile-builtin,round-builtin,oct-method,standarderror-builtin,hex-method,import-star-module-level,indexing-exception,map-builtin-not-iterating,old-ne-operator,setslice-method,input-builtin,apply-builtin,range-builtin-not-iterating,xrange-builtin,parameter-unpacking,no-absolute-import,old-raise-syntax,dict-iter-method,unicode-builtin,unpacking-in-except,old-division,file-builtin,next-method-called,useless-suppression,raw_input-builtin,intern-builtin,getslice-method,dict-view-method,cmp-builtin,coerce-builtin,line-too-long,missing-docstring,protected-access,global-statement,too-many-arguments,too-many-branches,too-many-locals,bare-except,invalid-name,too-many-statements,broad-except,too-many-instance-attributes,too-many-public-methods,too-few-public-methods,similarities,no-else-return
never-returning-functions=dmt.commonPy.utility.panic,sys.exit
[REPORTS]
......@@ -344,7 +343,7 @@ max-args=5
# Argument names that match this expression will be ignored. Default to name
# with leading underscore
ignored-argument-names=_.*
ignored-argument-names=_.*|unused.*|dummy.*
# Maximum number of locals for function / method body
max-locals=15
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment