Skip to content

web3.providers.ipc.get_default_ipc_path() returned None instead of str #2911

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

Closed
antazoey opened this issue Apr 11, 2023 · 2 comments · Fixed by #2917
Closed

web3.providers.ipc.get_default_ipc_path() returned None instead of str #2911

antazoey opened this issue Apr 11, 2023 · 2 comments · Fixed by #2917

Comments

@antazoey
Copy link
Contributor

antazoey commented Apr 11, 2023

  • 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 and/or join the conversation
on discord.

@antazoey
Copy link
Contributor Author

antazoey commented Apr 11, 2023

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

    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"
        )

@kclowes
Copy link
Collaborator

kclowes commented Apr 13, 2023

OS: macky whacky

This is cracking me up 😆

It would be a small breaking change to return the path even if it doesn't exist, but I changed the type and made the return None explicit in #2917. I don't see a problem with returning the path whether or not it exists, so I'll add this issue to our v7 megathread

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 a pull request may close this issue.

2 participants