Commit 1faa2235 authored by Thanassis Tsiodras's avatar Thanassis Tsiodras

Better attempt to appease mypy.

parent e95c60e4
Pipeline #1764 failed with stage
in 22 seconds
......@@ -228,7 +228,7 @@ of each SUBPROGRAM param.'''
panic(str(e))
def SpecialCodes(asnFile: str) -> None:
def SpecialCodes(asnFile: Optional[str]) -> None:
'''This function handles the code generations needs that reside outside
the scope of individual parameters (e.g. it needs access to all ASN.1
types). This used to cover Dumpable C/Ada Types and OG headers.'''
......@@ -393,7 +393,7 @@ def ProcessAsync( # pylint: disable=dangerous-default-value
def ProcessCustomBackends(
# Taking list of tuples made of (spName, sp_impl, language, maybeFVname)
asnFile: str,
asnFile: Optional[str],
useOSS: bool,
SystemsAndImplementations: List[Tuple[str, str, str, str]]) -> None:
......@@ -430,6 +430,10 @@ def ProcessCustomBackends(
if lang.lower() == "vhdl":
workedOnVHDL = True # pragma: no cover
inform("Creating %s for %s.%s", lang.upper(), sp._id, sp_impl)
# Necessary for mypy, but guaranteed by the check above for empty sp._params.
assert asnFile is not None
for backend in getCustomBackends(lang):
backend.OnStartup(lang, asnFile, sp, sp_impl, commonPy.configMT.outputDir, maybeFVname, useOSS)
for param in sp._params:
......@@ -543,6 +547,7 @@ def main() -> None:
uniqueDataFiles[param._signal._asnFilename].setdefault(sp._language, [])
uniqueDataFiles[param._signal._asnFilename][sp._language].append(sp)
asnFile = None # type: Optional[str]
asn1files = list(uniqueDataFiles.keys())
if len(asn1files) == 1:
asnFile = asn1files[0]
......@@ -551,9 +556,10 @@ def main() -> None:
elif asn1files:
panic("There appear to be more than one ASN.1 files referenced (%s)..." % str(asn1files))
names = commonPy.asnParser.g_names
for node in names.values():
verify.VerifyRanges(node, names)
if asnFile is not None:
names = commonPy.asnParser.g_names
for node in names.values():
verify.VerifyRanges(node, names)
SystemsAndImplementations = commonPy.aadlAST.g_subProgramImplementations[:]
SystemsAndImplementations.extend(commonPy.aadlAST.g_threadImplementations[:])
......@@ -605,6 +611,9 @@ def main() -> None:
if modelingLanguage.lower() in ["gui_ri", "gui_pi", "vhdl", "rhapsody"]:
modelingLanguage = "C"
# Necessary for mypy, but guaranteed by the check above for empty sp._params.
assert asnFile is not None
if modelingLanguage in async_languages:
m = ProcessAsync(modelingLanguage, asnFile, sp, maybeFVname, useOSS, badTypes)
asynchronousBackends.add(m)
......@@ -613,7 +622,9 @@ def main() -> None:
# SystemsAndImplementation loop completed - time to call OnShutdown ONCE for each async backend that we loaded
for asyncBackend in asynchronousBackends:
asyncBackend.OnShutdown(modelingLanguage, asnFile, maybeFVname)
# Appeasing mypy: asnFile can be None here, so I checked all
# B mappers - no-one depends on a None value for the asnFile.
asyncBackend.OnShutdown(modelingLanguage, '' if not asnFile else asnFile, maybeFVname)
ProcessCustomBackends(asnFile, useOSS, SystemsAndImplementations)
......
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