How to call Python function from R reticulate in Rmarkdown

I have this Rmarkdown, with a python function:

---
title: "An hybrid experiment"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
runtime: shiny
---

    ```{r setup, include=FALSE}
    library(flexdashboard)
    library(reticulate)
    ```

    ```{python}
    def addTwo(number):
      return number + 2
    ```

And I try to use the function addTwo in a reactive context, so I tried this:

    ```{r}
    renderText({
      the_number <- py$addTwo(input$selector)
      paste0("The text is: ",the_number)
    })
    ```

But I got this error:

TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

Detailed traceback:
  File "<string>", line 2, in addTwo

I must be doing something wrong, please could you guide me to solve this problem?