Skip to content

Example Operator usage does not include import statements #49893

@jroachgolf84

Description

@jroachgolf84

What do you see as an issue?

When a user is leveraging our Operator docs (such as for the BashOperator: https://airflow.apache.org/docs/apache-airflow-providers-standard/stable/operators/bash.html), each code snippet "stands alone" in the sense that there are no import statements as part of the code block. In fact, there is no reference to where this Operator can be imported from. This is due to using something like the following in our documentation.

  .. exampleinclude:: /../../../airflow-core/src/airflow/example_dags/example_bash_operator.py
      :language: python
      :dedent: 4
      :start-after: [START howto_operator_bash]
      :end-before: [END howto_operator_bash]

Solving the problem

I think there are a couple of ways that we could solve this problem. However, I believe that it warrants more discussion, as this would be something that needs to be solved across almost every provider. I think the easiest would be including a snippet at the top of each page that includes where the Operator/Hook/Sensors etc. can be imported from, rather than redundantly adding an import statement to each code snippet.

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions