[publiqa_2] How to handle None and optional parameters

By default all steps that are created via the "Add step" dialogue should only create optional parameters.


It should always be possible to call up these methods in such a way that, for example, x=None is possible. This means that it should be possible to "invalidate" parameter values stored in the data store (data.yaml).


Example:


data.yaml:

module_1:
  common:
    x: Carol

Step:

@step
def new_step(x: str = None):
    """
    xy

    :param x: x
    """
    if x:
        logger.info('x is ' + x)
    else:
        logger.info('x is None')

SCENARIOS


Scenario A script:

import module_1

module_1.new_step(step_info='new step', x=None)

Scenario A expected report.log:

TestStep   step_1.new_step   Setup
TestStep   step_1.new_step   Step info: new step
TestStep   step_1.new_step   Start Step
TestStep   step_1.new_step   Provided step data:
TestStep   step_1.new_step   data_set=default
TestStep   step_1.new_step   x=None
TestStep   step_1.new_step   x is None
TestStep   step_1.new_step   Finish with OK

Scenario B script:

import module_1

module_1.new_step(step_info='new step')

Scenario B expected report.log:

TestStep   step_1.new_step   Setup
TestStep   step_1.new_step   Step info: new step
TestStep   step_1.new_step   Start Step
TestStep   step_1.new_step   Provided step data:
TestStep   step_1.new_step   data_set=default
TestStep   step_1.new_step   x=Carol
TestStep   step_1.new_step   x is Carol
TestStep   step_1.new_step   Finish with OK

Scenario C script:

import module_1

module_1.new_step(step_info='new step', x='Jennifer')

Scenario C expected report.log:

TestStep   step_1.new_step   Setup
TestStep   step_1.new_step   Step info: new step
TestStep   step_1.new_step   Start Step
TestStep   step_1.new_step   Provided step data:
TestStep   step_1.new_step   data_set=default
TestStep   step_1.new_step   x=Jennifer
TestStep   step_1.new_step   x is Jennifer
TestStep   step_1.new_step   Finish with OK

Scenario D: How to make x required from the steps generated by frontend:

@step
def new_step(x: str):
    """
    xy

    :param x: x
    """
    logger.info(x)

Scenario E: How to make x required from the steps generated by frontend, but also allowing passing x = None when user still wants to be able to call module_1.new_step(step_info='new step', x = None) :

@step
def new_step(x: str | None):
    """
    xy

    :param x: x
    """
    if x:
        logger.info(x)
    else:
        logger.info('x is None')
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us