Repository: spyder-ide/spyder

Issue:
Spyder open file dialog doesn't show special/hidden files on macOS 
## Description of your problem

**What steps will reproduce the problem?**
1. Open spyder 3.0.0beta4 (anaconda installation on OS X 10.11.5)
2. Click on Open File button
3. Using new open file dialog attempt to locate special/hidden files that are visible in the finder
4. Files aren't visible (see screen shot below; dialog on left, Finder window on right)

![spydernoshowhidden](https://cloud.githubusercontent.com/assets/3229632/16860934/305cbd56-49f1-11e6-9b09-de5ca9a14e1c.png)
## Versions and main components
- Spyder Version: 3.0.0beta4
- Python Version: Python 2.7.11 |Continuum Analytics, Inc.| (default, Dec  6 2015, 18:57:58)
- Operating system: OS X 10.11.5
## Dependencies

jedi >=0.8.1     :  0.9.0 (OK)
matplotlib >=1.0 :  1.4.3 (OK)
nbconvert >=4.0  :  4.2.0 (OK)
numpy >=1.7      :  1.9.2 (OK)
pandas >=0.13.1  :  None (NOK)
pep8 >=0.6       :  1.7.0 (OK)
psutil >=0.3     :  4.3.0 (OK)
pyflakes >=0.5.0 :  1.2.3 (OK)
pygments >=2.0   :  2.1.3 (OK)
qtconsole >=4.2.0:  4.2.1 (OK)
rope >=0.9.4     :  0.9.4 (OK)
sphinx >=0.6.6   :  1.4.1 (OK)
sympy >=0.7.3    :  None (NOK)
PyQt = 5.6
Qt = 5.6.0



Discussion:
I think to fix this we need to change the filter for **All files**. Thanks for reporting it :-)

On linux there is a context menu to show or hide hidden files. It's not the same on OSX ?

@Nodd the default looks like this:
![spyder_optionsdefault](https://cloud.githubusercontent.com/assets/3229632/16923207/fa13be04-4ccd-11e6-8920-27980b5a5510.png)
And toggling `Options` leads to:
![spyder_optionstoggle](https://cloud.githubusercontent.com/assets/3229632/16923218/0383e2fc-4cce-11e6-92d4-32ac3d271d26.png)

(_Note to self_) Something that could help:

http://stackoverflow.com/questions/30117068/qfiledialog-showing-hidden-files-although-system-setting-is-off

It's 2020 and I still can't open my .ipython directory in Spyder... Any update? :))
No longer the case with 4.x


<img width="743" alt="Screen Shot 2020-04-11 at 21 12 48" src="https://user-images.githubusercontent.com/3627835/79058906-3ad15980-7c39-11ea-8f90-00b4a334d79d.png">

Closing @ccordoba12 ?
I use Spyder 4.1.2, MacOS Catalina 10.15.3, and my home directory (which indeed contains a .ipython directory), shows like this:
<img width="797" alt="Screenshot 2020-04-12 at 11 04 32 am" src="https://user-images.githubusercontent.com/4457898/79066170-a5bc7800-7cad-11ea-8f10-03a18648f326.png">
Either  I am doing something wrong with configuration (which is the most likely), or the problem is still there for MacOS.
Sorry I missed the open part. Will fix this:-)
Actually @MattACDC there is nothing to fix you need to use `Cmd+Shift+.` when you have the dialog open... that is the Mac Way

https://osxdaily.com/2011/03/01/show-hidden-files-in-mac-os-x-dialog-boxes-with-commandshiftperiod/
@goanpeca Oh, I see, it works, cheers mate!
@ccordoba12 @goanpeca it seems that the `CMD+Shift+.` works to view the files, but you can't select them to open the file in Spyder 4.1.2.

Or reading the above https://github.com/spyder-ide/spyder/issues/3291#issuecomment-612604777, maybe @goanpeca fixed this in 4.1.3, will update and try again.
@ccordoba12 @goanpeca bad news, this is still an issue for 4.1.3, so please reopen

Default open:
<img width="911" alt="Screen Shot 2020-05-27 at 2 41 54 PM" src="https://user-images.githubusercontent.com/3229632/83075203-4da4bf80-a028-11ea-919a-76d729ba3b9e.png">
`CMD+Shift+.` open:
<img width="911" alt="Screen Shot 2020-05-27 at 2 42 01 PM" src="https://user-images.githubusercontent.com/3229632/83075211-509fb000-a028-11ea-80d9-dfcd19ca67a3.png">
But unfortunately, the `.dotfiles` aren't selectable to open
@goanpeca thanks. As an FYI, I am currently on MacOS 10.14.6, let me know if you want any other diagnostic info
@goanpeca as a workaround, you can still drag and drop a file into the editor window so while it's a bit annoying, Spyder 4.1.3 can still edit these files (assuming you can figure out the drag and drop open)
Is this possible in other editors or IDEs, e.g. VSCode? If not, I'd say we should close this one because it really doesn't have to do with Spyder but with the open dialog provided by macOS. Besides, the files can be opened from Files just fine.
Yep, see below
<img width="1054" alt="Screen Shot 2020-05-27 at 3 15 53 PM" src="https://user-images.githubusercontent.com/3229632/83077776-ff45ef80-a02c-11ea-9ae9-3c08780b932b.png">
[VSCode 1.40.1, and also tested after updating to 1.45.1]
Maybe this could help: https://www.qtcentre.org/threads/67923-Get-QFileDialog-to-display-dot-folder-files

Although I think we currently use the static method `getopenfilenames` to get the files to open and that doesn't receive the filter flags (like `QDir.Hidden`)
Thanks for the heads up @dalthviz and @durack1. I will try to get this fixed for the next 4.1.4 release.

Cheers!

Resolving patch:
diff --git a/spyder/plugins/editor/plugin.py b/spyder/plugins/editor/plugin.py
--- a/spyder/plugins/editor/plugin.py
+++ b/spyder/plugins/editor/plugin.py
@@ -21,7 +21,7 @@
 
 # Third party imports
 from qtpy.compat import from_qvariant, getopenfilenames, to_qvariant
-from qtpy.QtCore import QByteArray, Qt, Signal, Slot
+from qtpy.QtCore import QByteArray, Qt, Signal, Slot, QDir
 from qtpy.QtPrintSupport import QAbstractPrintDialog, QPrintDialog, QPrinter
 from qtpy.QtWidgets import (QAction, QActionGroup, QApplication, QDialog,
                             QFileDialog, QInputDialog, QMenu, QSplitter,
@@ -1916,6 +1916,7 @@ def load(self, filenames=None, goto=None, word='',
             c_fname = self.get_current_filename()
             if c_fname is not None and c_fname != self.TEMPFILE_PATH:
                 basedir = osp.dirname(c_fname)
+
             self.redirect_stdio.emit(False)
             parent_widget = self.get_current_editorstack()
             if filename0 is not None:
@@ -1923,20 +1924,41 @@ def load(self, filenames=None, goto=None, word='',
                                             osp.splitext(filename0)[1])
             else:
                 selectedfilter = ''
+
             if not running_under_pytest():
-                filenames, _sf = getopenfilenames(
-                                    parent_widget,
-                                    _("Open file"), basedir,
-                                    self.edit_filters,
-                                    selectedfilter=selectedfilter,
-                                    options=QFileDialog.HideNameFilterDetails)
+                # See: spyder-ide/spyder#3291
+                if sys.platform == 'darwin':
+                    dialog = QFileDialog(
+                        parent=parent_widget,
+                        caption=_("Open file"),
+                        directory=basedir,
+                    )
+                    dialog.setNameFilters(self.edit_filters.split(';;'))
+                    dialog.setOption(QFileDialog.HideNameFilterDetails, True)
+                    dialog.setFilter(QDir.AllDirs | QDir.Files | QDir.Drives
+                                     | QDir.Hidden)
+                    dialog.setFileMode(QFileDialog.ExistingFiles)
+
+                    if dialog.exec_():
+                        filenames = dialog.selectedFiles()
+                else:
+                    filenames, _sf = getopenfilenames(
+                        parent_widget,
+                        _("Open file"),
+                        basedir,
+                        self.edit_filters,
+                        selectedfilter=selectedfilter,
+                        options=QFileDialog.HideNameFilterDetails,
+                    )
             else:
                 # Use a Qt (i.e. scriptable) dialog for pytest
                 dialog = QFileDialog(parent_widget, _("Open file"),
                                      options=QFileDialog.DontUseNativeDialog)
                 if dialog.exec_():
                     filenames = dialog.selectedFiles()
+
             self.redirect_stdio.emit(True)
+
             if filenames:
                 filenames = [osp.normpath(fname) for fname in filenames]
             else:


Test patch: