[Python] PyCharm not Indenting After Newline on Extremely Specific File

Discussão em 'Python' iniciado por Stack, Março 30, 2025.

  1. Stack

    Stack Membro Participativo

    I'm experiencing an infuriating issue in PyCharm. For some reason, within a specific file named "DataStorage.py", when I press the "Enter" key after a function or class declaration, it does not auto-indent as it usually would. Instead, it just moves the cursor to a new line with a single space. Additionally, the "Tab" key, which typically indents code, is now only producing spaces. This behavior is confined to this SPECIFIC file. If I copy all the code in that file into a new .py file, the issue DOES NOT occur, UNLESS I try to start using that file in other places across my code, and then it suddenly starts happening again.

    Because I was asked to further clarify, here's a detailed breakdown of the issue:

    -I have a file called "DataStorage.py" in a large PyCharm project I'm working on.

    -For this specific file, and only for this specific file, I am unable to create tab characters anymore.

    -If I press the "tab" key, it simply creates a space instead of a tab.

    -If PyCharm tries to automatically create a tab, for instance after I declare a function and hit "enter" to go to the next line, it tries to automatically tab for me but instead creates a single space.

    -My tabs are currently set as "4 spaces" in the Pycharm settings. I have set this to every conceivable option and not once did it even effect the tabbing done in DataStorage.py

    =This only occurs in this one SPECIFIC file. All other files, I can create tabs (4 spaces) without any issues.


    Steps I've taken to resolve the issue:

    -Checked the Editor > Code Style > Python settings to ensure the correct indentation settings. -Restarted PyCharm. -Completely reinstalled PyCharm. -Completely changed PyCharm versions -Deleted and recloned the entire project from Github -Reset all Pycharm settings, both on a project level and global level -Verified that the issue is not present in other IDEs with the same file. -Deleting the actual contents of DataStorage.py and trying it with a single function - still occurs

    I just don't get what's happening. This issue randomly started happening while I was in the middle of coding this file. I think it MIGHT have occurred when I accidentally opened the search everywhere menu by double-tapping shift, but I've checked literally every single setting there and nothing's helped. Maybe it was a different menu that popped up? I closed it so fast when it happened that I didn't get a good look.

    Any help would be greatly appreciated, as I'm completely out of ideas and so is ChatGPT. Thanks in advance!

    Continue reading...

Compartilhe esta Página