Describe your changes
I introduced a way to check check attributes with the type typing.Literal (The check supports python 2 and python 3).
I also created an error object LiteralError for the cases when the type check fails.
Note that I also made changes to _validate_elements function, because having type.Literal, inside isinstance function,
yields the error: TypeError: typing.Literal cannot be used with isinstance().
Testing performed
I copied the test structure of other features in the project, the tests of typing.Literal test it as the single type of an attribute,
and test it as a type inside a "container" type, for example as the type typing.List[typing.Literal['a', 'b', 'c']].
Signed-off-by: lironhl liron.lavy@gmail.com
closes #58
Describe your changes I introduced a way to check check attributes with the type
typing.Literal
(The check supportspython 2
andpython 3
). I also created an error objectLiteralError
for the cases when the type check fails. Note that I also made changes to_validate_elements
function, because havingtype.Literal
, insideisinstance
function, yields the error:TypeError: typing.Literal cannot be used with isinstance()
.Testing performed I copied the test structure of other features in the project, the tests of
typing.Literal
test it as the single type of anattribute
, and test it as a type inside a "container" type, for example as the typetyping.List[typing.Literal['a', 'b', 'c']]
.