Unwanted __init__.py being generated when moving scripts
Answered
Steps to reproduce:
- Create an empty Python project
- Create a directory (not a package)
- Create a Python file
- Move the file into the directory
A
__init__.py
file will be created in the directory.
How can I disable this behavior?
Please sign in to leave a comment.
Hi Claas Meiners! Disable Search for references option in move window:
Just a note that if you use a pip namespace https://packaging.python.org/en/latest/guides/packaging-namespace-packages/
Then moving a file within your sub package will add a __init__.py file to the namespace which will cause interference with the installed namespace in the virtualenv.
I don't think intellij should be adding __init__.py files for pre-existing folders, it's okay if the move creates folders though.
I am having the same issue and it is frustrating. Pycharm should not be adding an __init__.py file to a namespace package. Disabling "Search for reference" is not a good solution either because we typically want references to be updated.
Agreed, Pavel's solution above is like killing the patient to cure the cancer
Hey, is there a solution for this instead of disabling the "Search for reference"?
Honestly, this is the type of stuff that makes me want to move to vim. This should 1000% be configurable as a setting and its incredibly debatable whether this should be a default. It is extremely easy to miss this and then all of a sudden you recursively have delete these unwanted files…
Still no update? And why is this marked as `Answered`?
This hasn't been answered or fixed.
It's 2024 and we dont need __init__.py any more. Do not create these files! This should be such an easy fix, dissapointing no one has taken care of it already.
Still a damn problem. Very frustrating. Moving to VisualCode