Repository: jaraco/path

Issue:
`path.Path().files()` fails with `FileNotFoundError`
```python
>>> import path, pathlib
>>> pathlib.Path()
WindowsPath('.')
>>> path.Path()
Path('')
>>> list(pathlib.Path().iterdir())
[WindowsPath('.git'),
 WindowsPath('.idea'),
 WindowsPath('LICENSE'),
 WindowsPath('pyproject.toml'),
 WindowsPath('README.rst'),
 WindowsPath('setup.cfg')]
>>> path.Path().files()
Traceback (most recent call last):
  File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\site-packages\IPython\core\interactiveshell.py", line 3505, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-43-109000f98fc0>", line 1, in <module>
    path.Path().files()
  File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\site-packages\path\__init__.py", line 514, in files
    return [p for p in self.listdir(*args, **kwargs) if p.isfile()]
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\a\AppData\Local\Programs\Python\Python311\Lib\site-packages\path\__init__.py", line 492, in listdir
    return list(filter(match, (self / child for child in os.listdir(self))))
                                                         ^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 3] The system cannot find the path specified: Path('')
>>> path.Path('.').files()
[Path('.\\LICENSE'),
 Path('.\\pyproject.toml'),
 Path('.\\README.rst'),
 Path('.\\setup.cfg')]
```

I expect `path.Path().files()` to work just like `path.Path('.').files()`, but it currently raises error. Is that intentional or is it a bug?
This is not a Windows-specific issue. There is a similar error on my Linux machine: `FileNotFoundError: [Errno 2] No such file or directory: Path('')`.


Comments:

Patch:
diff --git a/newsfragments/216.feature.rst b/newsfragments/216.feature.rst
new file mode 100644
index 0000000..ffa5f9d
--- /dev/null
+++ b/newsfragments/216.feature.rst
@@ -0,0 +1,1 @@
+Use '.' as the default path.
\ No newline at end of file
diff --git a/path/__init__.py b/path/__init__.py
index 7d46d1d..2283175 100644
--- a/path/__init__.py
+++ b/path/__init__.py
@@ -142,7 +142,10 @@ class Path(str):
     .. seealso:: :mod:`os.path`
     """
 
-    def __init__(self, other=''):
+    def __new__(cls, other='.'):
+        return super().__new__(cls, other)
+
+    def __init__(self, other='.'):
         if other is None:
             raise TypeError("Invalid initial value for path: None")
         with contextlib.suppress(AttributeError):


Test patch:
diff --git a/test_path.py b/test_path.py
index d105369..0bc0440 100644
--- a/test_path.py
+++ b/test_path.py
@@ -78,6 +78,12 @@ class TestBasics:
             d = Path('D:\\')
             assert d.relpathto(boz) == boz
 
+    def test_construction_without_args(self):
+        """
+        Path class will construct a path to current directory when called with no arguments.
+        """
+        assert Path() == '.'
+
     def test_construction_from_none(self):
         """ """
         with pytest.raises(TypeError):
@@ -424,7 +430,7 @@ def test_chroot(monkeypatch):
     results = []
     monkeypatch.setattr(os, 'chroot', results.append)
     Path().chroot()
-    assert results == ['']
+    assert results == [Path()]
 
 
 @pytest.mark.skipif("not hasattr(Path, 'startfile')")
@@ -432,7 +438,7 @@ def test_startfile(monkeypatch):
     results = []
     monkeypatch.setattr(os, 'startfile', results.append)
     Path().startfile()
-    assert results == ['']
+    assert results == [Path()]
 
 
 class TestScratchDir: