Skip to content

PlutusData parsing does not handle modern type hints #287

Open
@theeldermillenial

Description

@theeldermillenial

Describe the bug
PlutusData classes honor old type hints (e.g. List[bytes]) by using issubclass.

Modern type hints (e.g. list[bytes]) fail because list is not a class.

This is the guilty line of code:

if inspect.isclass(f.type) and not issubclass(f.type, valid_types):

To Reproduce
Create a PlutusData class with modern type hints and try to instantiate.

from pycardano import PlutusData

class Test(PlutusData):
    a: list[bytes]

Test(a=[b'hello', b'world'])

Environment and software version (please complete the following information):

  • PyCardano Version 0.10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions