Skip to content

Feature: Change to another layout [src] #720

Open
@CarliJoy

Description

@CarliJoy

Follow up on the discussion in #488.

The MR suggested to change to a flat layout to activate typing easily (see #305).

@totallyzen brought the argument:

Since I wrote the refactor to the current core and modules, I can chime in a bit.

There is a very simple reason why it is core and modules -> it is because all major testcontainers language flavors use these. I don't think I'd want to deviate from that as it allows the TC mainline documentation to converge and easily match support across languages (automation can be built for it, and issues tracked across language flavours)

I wish we had better automation and support from the TC staff (I'm only a volunteer myself like @alexanderankin) but this is what we've got for now.

However, after looking at the official .NET project, I find this argument weak. The .NET project doesn't follow this structure—there is no core or modules, only src and tests folders.

The current layout introduces several issues:

  1. It is complex and hard to understand, as only with some Poetry-specific setup are the different folders combined.
  2. It makes running poetry pytest to test the project nearly impossible due to "import file mismatches."
  3. It suggests the existence of subprojects like testcontainers-core (which actually exists on PyPi, created by @tillahoffmann), adding confusion.
  4. Properly type-checking the project is difficult because mypy expects the entire project (not only parts) to be typed when importing, and it checks for the existence of py.typed.

I propose adopting the src-layout, which has been embraced by many modern Python packages. This would:

  • Clarify the difference between tests for the final package and tests in "development mode."
  • Allow running pytest from the project root, reducing the need for a complex Makefile just to run tests. Tests for different modules can still be organized into subfolders in the tests directory.

Most importantly, this change would reduce complexity, enabling Python developers to contribute more easily with less cognitive overhead.

Lastly, it would mirror the structure of the official .NET project. :)

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