Skip to content

Commit 2c06bce

Browse files
committed
Fix error message on invalid ymmsl_version tag
1 parent f3030b2 commit 2c06bce

File tree

6 files changed

+21
-9
lines changed

6 files changed

+21
-9
lines changed

ymmsl/command_line.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import click
22
import os
33
from shutil import copyfile
4-
from typing import Optional, TextIO, Type, Union
4+
from typing import Dict, Optional, TextIO, Type, Union
55
import warnings
66

77
from ymmsl.conversion.converter import DowngradeError
@@ -31,7 +31,7 @@ def ymmsl() -> None:
3131
pass
3232

3333

34-
_version_tag_to_type = {
34+
_version_tag_to_type: Dict[str, Type] = {
3535
'v0.1': v0_1.PartialConfiguration,
3636
'v0.2': v0_2.Configuration,
3737
}

ymmsl/document.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
class Document:
1+
from abc import ABC
2+
3+
4+
class Document(ABC):
25
"""Base class for ymmsl documents of all versions"""
36
def __init__(self) -> None:
47
pass

ymmsl/tests/test_io.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import ymmsl
2+
import yatiml
3+
4+
import pytest
5+
6+
7+
def test_invalid_version() -> None:
8+
"""This is a regression test, the error was really confusing"""
9+
with pytest.raises(yatiml.RecognitionError):
10+
ymmsl.load('ymmsl_version: v0_1')

ymmsl/v0_1/configuration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ def check_consistent(self) -> None:
341341

342342
@classmethod
343343
def _yatiml_recognize(cls, node: yatiml.UnknownNode) -> None:
344+
Document._yatiml_recognize(node)
344345
node.require_attribute('model', Model)
345346
node.require_attribute('implementations')
346347
node.require_attribute('resources')

ymmsl/v0_1/document.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
class Document(DocumentBase):
77
"""Represents a yMMSL document.
88
9-
This gets mixed in with a top-level content class, and takes
10-
care of a special ymmsl_version attribute in the root of the
11-
YAML file.
9+
This gets specialised by a top-level content class, and takes care of a special
10+
ymmsl_version attribute in the root of the YAML file.
1211
"""
1312

1413
@classmethod

ymmsl/v0_2/document.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
class Document(DocumentBase):
77
"""Represents a yMMSL document.
88
9-
This gets mixed in with a top-level content class, and takes
10-
care of a special ymmsl_version attribute in the root of the
11-
YAML file.
9+
This gets specialised by a top-level content class, and takes care of a special
10+
ymmsl_version attribute in the root of the YAML file.
1211
"""
1312

1413
@classmethod

0 commit comments

Comments
 (0)