This is a general design decision. Full stop. I am not a core Python developper, so I can just try to guess the rationale behind it.
It is indeed frustrating... until you understand that everything works smoothly as soon as you start to correctly package your projects. The rule is that something requires more than one file (and what you have shown is already complex enough...) it should be packaged according to the PyPA rules.
Not only you immediately gain relative imports because the whole project is a package, but installing the project on a new system and have it immediately accessible becomes a piece of cake. You just declare any script as command line entry points, and they will end in the path immediately after installation. If you use high level tools to manage it (Pycharm or hatch or...) you also gain easy testing, including against a range of Python versions at no cost.
That is the reason why I suspect that the underlying reason for not allowing relative imports outside packages is to encourage developpers to always package any project requiring more than one single script file.
In order to be more explicit with the problems of script within a packaged project, I can provide you a direct link to the page about the initial configuration of the pyproject.toml file.
Any function can be turned into an executable by declaring it in the project.scripts table.
Your example could become:
my_project/
├── pyproject.toml
├── my_project/
├── __init__.py
├── module1.py
├── module2.py
├── script1.py
└── script2.py
Then in your pyproject.toml you could add:
[project.scripts]
script1 = "my_project.script1:main"
script2 = "my_project.script2:main"
Installation would automatically generate the commands script1 and script2 that would automatically call the function main in respectively script1.py and script2.py.
Learning how to package a project does require some work (even if a tool like hatch can give you a default project skeleton that you only have to edit) but in the long term, you will realize that it really was worth it.
sys.appendinstead of how to actually package their projects.blackformatter) But you don't have to, that's the point! If you actually package your project and install it (possibly in editable mode) then your scrips can jsut import the package anywhere