jeffthibault / python-nostr

A Python library for Nostr
MIT License
275 stars 88 forks source link

Python 3.11 and are the examples up to date? #87

Open brianoflondon opened 1 year ago

brianoflondon commented 1 year ago

I'd love to use this but I'm already working in Python 3.11. I can't even import the library properly.

BTW I added it to my project with poetry add git+https://github.com/jeffthibault/python-nostr.git instead of PyPi.

First error trying to use the connect to relays example is this:

ValueError: mutable default <class 'nostr.relay.RelayPolicy'> for field policy is not allowed: use default_factory

A quick look at the code and I can't understand how this:

relay_manager.open_connections(
    {"cert_reqs": ssl.CERT_NONE}
)  # NOTE: This disables ssl certificate verification

Will work as I can't see a open_connections method on that class, is the doc out of date?

I would like to provide NIP-57 support to the people all using my non-custodial NIP-05 system but I really don't have the capacity to dig into this library and fix it at this time.

I tried to install for Dev but had a bunch of problems which I can expand on if it helps anyone, suffice to say I can't get a dev environment working properly.

ghost commented 1 year ago

i had some issues too, but i couldn't get it to work so i moved to a fork of this library which is located here

Everything works, sadly no docs yet so you'll need to look through the code for answers. If you need help, feel free to mention me

Jxck-S commented 1 year ago
ry

Docs are def out of date. open_connnections and close are both deprecated. Connecting is auto-done when adding a relay.

For ValueError: mutable default <class 'nostr.relay.RelayPolicy'> for field policy is not allowed: use default_factory Same problem mentioned here https://github.com/jeffthibault/python-nostr/issues/82#issuecomment-1537271314

This is the fix In relay.py add field to the dataclasses import from dataclasses import dataclass, field

Also change line 37 to use the default factory field policy: RelayPolicy = field(default_factory=RelayPolicy)