And we could do the same with others:

airflow-core
task-sdk
tests-common

That would guarantee that those will be pure folders and not accidentally
turn into python packages.

For example now we have this:

task_sdk
       \__init_.py
       src
          \ - airflow
                    \ sdk


And with implicit namespaces, someone could easily do :

`from task_sdk.src.airflow.sdk`

In fact we are already doing it for task_sdk tests:

from task_sdk.tests.api.test_client import make_client

One reason was conftest.py confusion when we had providers but we should be
able to remove it when we move tests_common.

By having the "root" of each of the sub-project the same as
"pyproject.toml` we got it way easier to import and work on
independently from the whole "airflow" repo.

J.


On Tue, Feb 25, 2025 at 4:53 PM Jarek Potiuk <ja...@potiuk.com> wrote:

> Actually - after experiencing unrelated error in my PR for "legacy"
> namespace packages -
> https://github.com/apache/airflow/actions/runs/13524796336/job/37793501020?pr=47064#step:6:36
> I have a way better idea:
>
> ```
> tests-common <- folder
>            \pyproject.toml
>            \src
>                \tests_common <- Python package
> ```
>
> tests-common (note `-` not `_`) - is not a valid python package name, but
> it's a perfectly valid folder name. And `from tests_common` will never be
> misinterpreted this way,
>
> On Tue, Feb 25, 2025 at 4:52 PM Ash Berlin-Taylor <a...@apache.org> wrote:
>
>> Yeah, but why would we confuse things more by putting it in the already
>> messy airflow namespace? That feels like a step backwards to me.
>>
>> > On 25 Feb 2025, at 15:23, Jarek Potiuk <ja...@potiuk.com> wrote:
>> >
>> >> This is the only bit I’m confused about — what the `airflow.` prefix?
>> >
>> > Precisely to avoid that `from tests_common" will be used from the root
>> of
>> > the project (commonly added to PYTHONPATH).
>> >
>> > The whole discussion is about how to avoid this.
>> >
>> > J.
>> >
>> >
>> >
>> >
>> > On Tue, Feb 25, 2025 at 3:22 PM Ash Berlin-Taylor <a...@apache.org>
>> wrote:
>> >
>> >> This is the only bit I’m confused about — what the `airflow.` prefix?
>> >>
>> >>> On 25 Feb 2025, at 13:40, Jarek Potiuk <ja...@potiuk.com> wrote:
>> >>>
>> >>> from airflow.tests_common
>> >>
>> >>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscr...@airflow.apache.org
>> For additional commands, e-mail: dev-h...@airflow.apache.org
>>
>>

Reply via email to