PyCharm Code Folding - Type Annotations
Hello, I recently updated my PyCharm from 2022 to 2024. I've found a few differences in general IDE behavior, most of which I've been able to adjust to my liking in Preferences, but this one issue I cannot, and it's driving me crazy haha…
I absolutely LOVE the Code > Folding > Collapse All feature. It's pretty much the first shortcut-key I hit when I open any code file, making navigating and reading through code easier on the eyes; for me anyway. Also, where I currently work we've gotten into the habit of using type annotations in our python code, so it's all over the codebase we maintain.
My issue here is, in this latest update, the Collapse All feature is now also collapsing type annotations. This is probably intentional, but I would really love it if I could change the Code Folding behavior to leave type annotations alone.
I'm aware of a setting found at Editor > General > Code Folding >> Fold by default > Python >Type Annotations, but this is the exact opposite of what I'm looking for.
Below are some images demonstrating my dilemma.
Code w/ No Folding:
Code Collapsed in 2024 (w/ class manually expanded):
Code Collapsed in 2022 (w/ class manually expanded), (desired):
Hopefully this shows what I'm talking about. Trying to look at code at this level with types hidden is kinda awkward, and having to manually expand each collapsed-type, which is a lot in my normal working day codebase, is extremely inconvenient. Maybe it's just me, but I feel code folding of type annotations does more harm than good.
My question is: Is there anyway to configure code folding, so that type annotations are left alone when collapsing code, specifically for the Collapse All feature? If not, are there any plans to maybe address this?
Please sign in to leave a comment.
I would like to know the answer to this also. Type annotations are best seen.
Same here. I would really like to have the option to preserve the type hints when collapsing all.
No answer yet
Raised an issue here: https://youtrack.jetbrains.com/issue/WEB-69687/PyCharm-folds-type-hints please upvote