Skip to content

Commit

Permalink
miniwdl check: warning for import of newer WDL version
Browse files Browse the repository at this point in the history
  • Loading branch information
mlin committed Feb 19, 2024
1 parent 1109a80 commit 6dfe837
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
21 changes: 21 additions & 0 deletions WDL/Lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,27 @@ def document(self, obj: Tree.Document) -> Any:
)


@a_linter
class ImportNewerWDL(Linter):
# Document imports a document with a newer WDL version
def document(self, obj: Tree.Document) -> Any:
doc_version = self._version_order(obj.effective_wdl_version)
for imp in obj.imports:
if self._version_order(imp.doc.effective_wdl_version) > doc_version:
self.add(
obj,
"imported document has newer WDL version",
pos=imp.pos,
)

def _version_order(self, wdl_version: str) -> int:
if wdl_version == "draft-2":
return 2
elif wdl_version == "development":
return 99
return int(wdl_version.replace(".", ""))


@a_linter
class ForwardReference(Linter):
# Ident referencing a value or call output lexically precedes Decl/Call
Expand Down
2 changes: 2 additions & 0 deletions tests/test_3corpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ class dxWDL(unittest.TestCase):
"UnverifiedStruct": 3,
"Deprecated": 2,
"UnexpectedRuntimeValue": 1,
"ImportNewerWDL": 1,
},
blocklist=["check_quant", "incomplete_call", "issue596"],
)
Expand Down Expand Up @@ -437,6 +438,7 @@ class Contrived(unittest.TestCase):
"UnverifiedStruct": 3,
"Deprecated": 3,
"UnexpectedRuntimeValue": 1,
"ImportNewerWDL": 2,
},
check_quant=False,
blocklist=["incomplete_call"],
Expand Down

0 comments on commit 6dfe837

Please sign in to comment.