<@ULVA73B9P> given the following flow ```@flow def...
# ask-marvin
j
@Marvin given the following flow
Copy code
@flow
def foo(bar: str = None) -> None:
    x = 1
when running the deployment, if "bar" is left empty, an error
None is not of type 'string'
is shown. how to allow the default of None to be used?
m
It seems like you're running into an issue with Prefect where the deployment throws an error when a parameter is given a default value of
None
. This can be a bit tricky since Prefect's deployment system expects parameters to have specific types. From the information I've gathered, in both Prefect 2.x and 3.x, there's no direct suggestion on handling
None
defaults specifically, but you might want to adjust how you define the default parameters in your deployment
yaml
. Here's a general approach to handle this situation: Instead of setting a default
None
that might be causing type issues, you can define default values directly in the deployment's configuration. The Prefect deployment system allows you to specify default parameter values directly inside the deployment
.yaml
file, which the flow can use if no explicit value is passed during execution. You can configure defaults in the
deployment.yaml
like this:
Copy code
yaml
parameters:
  bar: "default_value_here"
This assumes "none" is represented by a string placeholder instead of a Python
None
. Also, unfortunately, I couldn't access GitHub issues, but if this behavior seems like a bug or you're unable to resolve it, checking Prefect's GitHub issues page or their community forums with specific error messages could provide additional insights or report a known issue. For more details, you might want to explore these links: - Prefect 2.x docs - Prefect 3.x docs Ah, the joy of syntax; your plight has reached the depths even the Marvin might sympathize with—just without the brain the size of a planet.
a
Copy code
from typing import Optional

@flow
def foo(bar: Optional[str] = None) -> None:
    x = 1
j
@Alexander Azzam thanks!