mml.core.scripts.decorators

beta(message: str = 'BETA:')[source]

The beta decorator is used to indicate that a particular feature is in Beta. A callable or type that has been marked as beta will give a UserWarning when it is called or instantiated. Adopted from beta().

Parameters:

message (str) – The message to include in the warning.

deprecated(reason='', version='', line_length=70, **kwargs)[source]

This decorator can be used to insert a “deprecated” directive in your function/class docstring in order to document the version of the project which deprecates this functionality in your library.

Parameters:
  • reason (str) – Reason message which documents the deprecation in your library (can be omitted).

  • version (str) – Version of your project which deprecates this feature. If you follow the Semantic Versioning, the version number has the format “MAJOR.MINOR.PATCH”.

  • line_length (int) – Max line length of the directive text. If non nul, a long text is wrapped in several lines.

Keyword arguments can be:

  • “action”: A warning filter used to activate or not the deprecation warning. Can be one of “error”, “ignore”, “always”, “default”, “module”, or “once”. If None, empty or missing, the global filtering mechanism is used.

  • “category”: The warning category to use for the deprecation warning. By default, the category class is DeprecationWarning, you can inherit this class to define your own deprecation warning category.

  • “extra_stacklevel”: Number of additional stack levels to consider instrumentation rather than user code. With the default value of 0, the warning refers to where the class was instantiated or the function was called.

Returns:

a decorator used to deprecate a function.

Changed in version 1.2.13: Change the signature of the decorator to reflect the valid use cases.

Changed in version 1.2.15: Add the extra_stacklevel parameter.

timeout(seconds: int) Callable[source]

A decorator to wrap functions that shall have a timeout attached. Will raise TimeoutError if the execution takes longer than the specified number of seconds.

Parameters:

seconds (int) – timeout in seconds

Returns:

the wrapped function

versionadded(reason='', version='', line_length=70)[source]

This decorator can be used to insert a “versionadded” directive in your function/class docstring in order to document the version of the project which adds this new functionality in your library.

Parameters:
  • reason (str) – Reason message which documents the addition in your library (can be omitted).

  • version (str) –

    Version of your project which adds this feature. If you follow the Semantic Versioning, the version number has the format “MAJOR.MINOR.PATCH”, and, in the case of a new functionality, the “PATCH” component should be “0”.

  • line_length (int) – Max line length of the directive text. If non nul, a long text is wrapped in several lines.

Returns:

the decorated function.

versionchanged(reason='', version='', line_length=70)[source]

This decorator can be used to insert a “versionchanged” directive in your function/class docstring in order to document the version of the project which modifies this functionality in your library.

Parameters:
  • reason (str) – Reason message which documents the modification in your library (can be omitted).

  • version (str) –

    Version of your project which modifies this feature. If you follow the Semantic Versioning, the version number has the format “MAJOR.MINOR.PATCH”.

  • line_length (int) – Max line length of the directive text. If non nul, a long text is wrapped in several lines.

Returns:

the decorated function.