Skip to content

return default ipc path whether it exists or not #3245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 26, 2024

Conversation

pacrob
Copy link
Contributor

@pacrob pacrob commented Feb 22, 2024

What was wrong?

Related to Issue #2911
Related to Issue #2854

How was it fixed?

Remove check to see if the .ipc file exists and just return the default value. Add tests.
Also, the default path for get_default_ipc_path was fixed in #3060, but doesn't look like it was for get_dev_ipc_path, so updated that too.

Todo:

Cute Animal Picture

image

@pacrob pacrob force-pushed the unconditionally-return-ipc-path branch from 0557671 to cb2372a Compare February 22, 2024 23:53
@pacrob pacrob requested review from kclowes, fselmo and reedsa February 22, 2024 23:54
Copy link
Contributor

@reedsa reedsa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about adding a parameterized test to check the paths are correctly returned from get_default_ipc_path() and get_dev_ipc_path()? I think sys.platform can be mocked to make that possible.

@@ -91,21 +91,15 @@ def get_default_ipc_path() -> Optional[str]:
ipc_path = os.path.expanduser(
os.path.join("~", "Library", "Ethereum", "geth.ipc")
)
if os.path.exists(ipc_path):
return ipc_path
return None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed in https://github.com/ethereum/web3.py/pull/2917/files the return None was added to make typing work. I think we can remove the Optional from the return type now that None is being removed.

@@ -91,21 +91,15 @@ def get_default_ipc_path() -> Optional[str]:
ipc_path = os.path.expanduser(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Since these ipc_path vars are not used anywhere else, just return in a single line.

Suggested change
ipc_path = os.path.expanduser(
return os.path.expanduser(

Copy link
Contributor

@reedsa reedsa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

Copy link
Contributor

@reedsa reedsa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My apologies, I did not mean to approve yet. Let me know what you think about testing those functions.

@pacrob pacrob force-pushed the unconditionally-return-ipc-path branch 2 times, most recently from 316c40b to e9dfc9b Compare February 23, 2024 22:58
@pacrob pacrob force-pushed the unconditionally-return-ipc-path branch from e9dfc9b to 4b27874 Compare February 23, 2024 23:00
@pacrob pacrob requested a review from reedsa February 23, 2024 23:11
Copy link
Contributor

@reedsa reedsa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, nice additions! 👍

@pacrob pacrob merged commit da71205 into ethereum:main Feb 26, 2024
@pacrob pacrob deleted the unconditionally-return-ipc-path branch February 26, 2024 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants