Hide files *only* from Project view

Answered

I love Python because of it's simplicity, but I hate the deicion to require __init__.py-files in every package folder. I always leave them empty, and it's annoying me that these empty files are stealing real-estate on my screen and making my project structures more cluttered when browsing for a file.

The only way I know to hide files is in the "File Types"-dialog, but this also hides them from the parser, so I get errors on all the libraries and modules that uses __init__.py-files. Is there a way to hide them only from the Project viewer?

2
17 comments

Hello Preben,

Right now PyCharm doesn't support such exclusions.

I love Python because of it's simplicity, but I hate the deicion to

require __init__.py-files in every package folder. I always leave them

empty, and it's annoying me that these empty files are stealing

real-estate on my screen and making my project structures more

cluttered when browsing for a file.

The only way I know to hide files is in the "File Types"-dialog, but

this also hides them from the parser, so I get errors on all the

libraries and modules that uses __init__.py-files. Is there a way to

hide them only from the Project viewer?

--

Dmitry Jemerov

Development Lead

JetBrains, Inc.

http://www.jetbrains.com/

"Develop with Pleasure!"

0

Has this changed in more recent versions of PyCharm (like the 2.0 version)?  I, too, would love to hide __init__.py files!

0

No. (And given that __init__.py files often contain code, we don't think it's a really good idea to hide them.)

0
Is it possible to only hide the __init__.py files when they are empty? This would be super useful and solve the problem
0
There is no such feature in PyCharm at the moment. (And implementing it would make it very difficult for a user to add code to __init__.py which was previously empty.)
0
In Python 3.3 you will not have to create an empty __init__.py file in order to mark a directory as a Python package. Any directory on your PYTHONPATH will be a Python package. See PEP-420 for more info. Note that this language change is not backwards compatible.
0
FWIW, I'd like this feature as well. I don't want to hide __init__.py files, but Eclipse project files.
0
Adam,
You can add the Eclipse project files to Settings | File Types | Files and folders to ignore. (This wouldn't work for __init__, but for the Eclipse projects this won't cause any issues.)
2

That's now Settings | Editor > File Types > Ignore files and folders (for those coming here from google).

 

3

I agree that it's a bad idea to hide `__init__.py` files as they are essential in Python...

But, I would love it if PyCharm could highlight/indicate when a file is empty so that I know that I don't have to open it to check whether it contains code.

1
Avatar
Permanently deleted user
3

I know why PyCharm can't implement hide specify files feature. This will not only effect which files you see but also effect python packages while indexing project tree.

For example: Try add virtualenv (eg. .env directory). You will not get any suggestions from 3rd library that installed via pip.

0

Showing __init__.py files particularly when empty, is just annoying and it's only matched by the inability to arranging the files and directories in a custom order .

0

If you do not change the __init__.py s often enough to always have them on, then there really is not a good reason to show them. Though I agree they should not be hidden by default.

`__init__.py` files can be hidden from the project tree by creating a new local scope in preferences -> Scopes.

Just add the pattern: `!file:*/__init__.py` and Apply.

Then at the top of the project tree change the display to the new scope you just created. 

Note, you'll need to toggle back to inspect these files or ensure you've selected the complete file scope for the project in find or other search modals.

3

Jrmanev. Thanks. Glad it helped. I still use this trick.

0

Scroll up 2 comments and you'll find the best answer ever

0

Please sign in to leave a comment.