Repository: ethereum/web3.py

Issue:
`web3.providers.ipc.get_default_ipc_path()` returned `None` instead of `str`
* Version: 6.0.0
* Python: 3.10
* OS: macky whacky
* `pip freeze` output

```
will provide if needed
```


### What was wrong?

The method `get_deafult_ipc_path()` located in `web3.providers.ipc` returned `None` even though its return type is documented as `str`.

I am not sure why it returned `None` in my case, probably forgot some flag in `geth`.

Edit: it returned None in my case because i was checking it before starting geth, so it didnt exist yet.

### How can it be fixed?

Either change type to `Optional[str]` or raise an error instead of returning `None` ?

---
**Note:** We prefer to use issues to track our work. If you think you've encountered a bug in web3py or 
have a feature request, you're in the right place. If you have implementation or usage questions, 
please refer to our [documentation](https://web3py.readthedocs.io/en/latest/) and/or join the conversation 
on [discord](https://discord.gg/GHryRvPB84).



Discussion:
For us, it is most useful to have this path even if it does not currently exist yet, since it may not exist at config time but may exist once starting geth, but it is also a flag for the geth cmd itself

```python
    if sys.platform == "darwin":
        return os.path.expanduser(os.path.join("~", "Library", "Ethereum", "geth.ipc"))

    elif sys.platform.startswith("linux") or sys.platform.startswith("freebsd"):
        return os.path.expanduser(os.path.join("~", ".ethereum", "geth.ipc"))

    elif sys.platform == "win32":
        return os.path.join("\\\\", ".", "pipe", "geth.ipc")

    else:
        raise ValueError(
            f"Unsupported platform '{sys.platform}'.  Only darwin/linux/win32/"
            "freebsd are supported.  You must specify the ipc_path"
        )
```

Resolving patch:
diff --git a/web3/providers/ipc.py b/web3/providers/ipc.py
--- a/web3/providers/ipc.py
+++ b/web3/providers/ipc.py
@@ -14,6 +14,7 @@
 )
 from typing import (
     Any,
+    Optional,
     Type,
     Union,
 )
@@ -85,24 +86,26 @@ def reset(self) -> socket.socket:
         return self.sock
 
 
-# type ignored b/c missing return statement is by design here
-def get_default_ipc_path() -> str:  # type: ignore
+def get_default_ipc_path() -> Optional[str]:
     if sys.platform == "darwin":
         ipc_path = os.path.expanduser(
             os.path.join("~", "Library", "Ethereum", "geth.ipc")
         )
         if os.path.exists(ipc_path):
             return ipc_path
+        return None
 
     elif sys.platform.startswith("linux") or sys.platform.startswith("freebsd"):
         ipc_path = os.path.expanduser(os.path.join("~", ".ethereum", "geth.ipc"))
         if os.path.exists(ipc_path):
             return ipc_path
+        return None
 
     elif sys.platform == "win32":
         ipc_path = os.path.join("\\\\", ".", "pipe", "geth.ipc")
         if os.path.exists(ipc_path):
             return ipc_path
+        return None
 
     else:
         raise ValueError(
@@ -111,22 +114,25 @@ def get_default_ipc_path() -> str:  # type: ignore
         )
 
 
-# type ignored b/c missing return statement is by design here
-def get_dev_ipc_path() -> str:  # type: ignore
+def get_dev_ipc_path() -> Optional[str]:
     if os.environ.get("WEB3_PROVIDER_URI", ""):
         ipc_path = os.environ.get("WEB3_PROVIDER_URI")
         if os.path.exists(ipc_path):
             return ipc_path
+        return None
+
     elif sys.platform == "darwin":
         tmpdir = os.environ.get("TMPDIR", "")
         ipc_path = os.path.expanduser(os.path.join(tmpdir, "geth.ipc"))
         if os.path.exists(ipc_path):
             return ipc_path
+        return None
 
     elif sys.platform.startswith("linux") or sys.platform.startswith("freebsd"):
         ipc_path = os.path.expanduser(os.path.join("/tmp", "geth.ipc"))
         if os.path.exists(ipc_path):
             return ipc_path
+        return None
 
     elif sys.platform == "win32":
         ipc_path = os.path.join("\\\\", ".", "pipe", "geth.ipc")


Test patch: