Skip to content

Explain better errors in EmulationConfig init #1025

@HaroldErbin

Description

@HaroldErbin

It would be helpful to give more information in errors thrown in EmulationConfig.__init__ such that it is easier to identify which particular argument fails.

For example, I am getting the following error:

  File "pulser/backend/config.py", line 276, in __init__
    raise TypeError(
TypeError: All entries in 'observables' must be instances of Observable. Instead, got instance of type <class 'str'>.

This requires a bit of work to identify the problematic observable. Changing the test on line 275 to:

if not isinstance(obs, Observable):
    raise TypeError(
        "All entries in 'observables' must be instances of "
        f"Observable. Instead, got instance of type {type(obs)}. "
        f"for observable {obs}."
    )

makes it much easier to identify the problem. Similar improvements can be done to other tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions