Skip to content

As part of redesign of parse methods in Model, consider to make sure that parser... #207

Open
@github-actions

Description

@github-actions

the typing allows output can be directly funnelled back as input, but which still change

the data, can be revalidated without altering the state. An example of such a Model is

the RomanNumeral Model below, given that the if statement where removed.

# TODO: As part of redesign of parse methods in Model, consider to make sure that parsers where

    roman_numerals = ('I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X')

    # TODO: As part of redesign of parse methods in Model, consider to make sure that parsers where
    #       the typing allows output can be directly funnelled back as input, but which still change
    #       the data, can be revalidated without altering the state. An example of such a Model is
    #       the RomanNumeral Model below, given that the if statement where removed.
    class RomanNumeral(Model[str]):
        """A roman numeral"""
        @classmethod
        def _parse_data(cls, data: str) -> str:
            if data in roman_numerals:
                return data
            number = int(data)
            assert 0 < number <= 10
            return roman_numerals[number - 1]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions