Skip to content

Commit f8623e7

Browse files
committed
return path directly
1 parent cb2372a commit f8623e7

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

web3/providers/ipc.py

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
)
1515
from typing import (
1616
Any,
17-
Optional,
1817
Type,
1918
Union,
2019
)
@@ -86,20 +85,15 @@ def reset(self) -> socket.socket:
8685
return self.sock
8786

8887

89-
def get_default_ipc_path() -> Optional[str]:
88+
def get_default_ipc_path() -> str:
9089
if sys.platform == "darwin":
91-
ipc_path = os.path.expanduser(
92-
os.path.join("~", "Library", "Ethereum", "geth.ipc")
93-
)
94-
return ipc_path
90+
return os.path.expanduser(os.path.join("~", "Library", "Ethereum", "geth.ipc"))
9591

9692
elif sys.platform.startswith("linux") or sys.platform.startswith("freebsd"):
97-
ipc_path = os.path.expanduser(os.path.join("~", ".ethereum", "geth.ipc"))
98-
return ipc_path
93+
return os.path.expanduser(os.path.join("~", ".ethereum", "geth.ipc"))
9994

10095
elif sys.platform == "win32":
101-
ipc_path = r"\\.\pipe\geth.ipc"
102-
return ipc_path
96+
return r"\\.\pipe\geth.ipc"
10397

10498
else:
10599
raise ValueError(
@@ -108,23 +102,19 @@ def get_default_ipc_path() -> Optional[str]:
108102
)
109103

110104

111-
def get_dev_ipc_path() -> Optional[str]:
105+
def get_dev_ipc_path() -> str:
112106
if os.environ.get("WEB3_PROVIDER_URI", ""):
113-
ipc_path = os.environ.get("WEB3_PROVIDER_URI")
114-
return ipc_path
107+
return os.environ.get("WEB3_PROVIDER_URI")
115108

116109
elif sys.platform == "darwin":
117110
tmpdir = os.environ.get("TMPDIR", "")
118-
ipc_path = os.path.expanduser(os.path.join(tmpdir, "geth.ipc"))
119-
return ipc_path
111+
return os.path.expanduser(os.path.join(tmpdir, "geth.ipc"))
120112

121113
elif sys.platform.startswith("linux") or sys.platform.startswith("freebsd"):
122-
ipc_path = os.path.expanduser(os.path.join("/tmp", "geth.ipc"))
123-
return ipc_path
114+
return os.path.expanduser(os.path.join("/tmp", "geth.ipc"))
124115

125116
elif sys.platform == "win32":
126-
ipc_path = os.path.join("\\\\", ".", "pipe", "geth.ipc")
127-
return ipc_path
117+
return os.path.join("\\\\", ".", "pipe", "geth.ipc")
128118

129119
else:
130120
raise ValueError(

0 commit comments

Comments
 (0)