Skip to content

Silent mode for runtime module import #5

@alonbl

Description

@alonbl

Hi,

In the output module there is a conditional and a raw usage of stdout.

try:
    from ts2python.typeddict_shim import TypedDict, GenericTypedDict, NotRequired, Literal
    # Overwrite typing.TypedDict for Runtime-Validation
except ImportError:
    print("Module ts2python.typeddict_shim not found. Only coarse-grained "
          "runtime type-validation of TypedDicts possible")

It is not a good practice of modules to write into stdout but use loggers or provide an API. A logger is not good in this early stage, so we left with an API or pre-setting.

As the warning is recoverable for a more primitive mode of operation which may be acceptable, please consider to have a conditional that is based on a variable that may be set before the import or some argument to the build to silent the warning.

Thanks,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions