Skip to content
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

python 3.10 support #220

Closed
robertcsapo opened this issue Jan 9, 2022 · 5 comments
Closed

python 3.10 support #220

robertcsapo opened this issue Jan 9, 2022 · 5 comments

Comments

@robertcsapo
Copy link
Contributor

ImportError: cannot import name 'Iterable' from 'collections' (/usr/local/lib/python3.10/collections/__init__.py)

options = {"fields": ["document", "diff", "action"]}
stream = client.stream(doc["ref"], options, on_start, on_error, on_version)
stream.start()
Traceback (most recent call last):
  File "/workspaces/faunadb/github/faunadb-python/example.py", line 3, in <module>
    from faunadb.client import FaunaClient
  File "/workspaces/faunadb/github/faunadb-python/faunadb/client.py", line 19, in <module>
    from faunadb.streams import Subscription
  File "/workspaces/faunadb/github/faunadb-python/faunadb/streams/__init__.py", line 1, in <module>
    from .client import Connection
  File "/workspaces/faunadb/github/faunadb-python/faunadb/streams/client.py", line 12, in <module>
    from hyper import HTTP20Connection
  File "/home/vscode/.local/lib/python3.10/site-packages/hyper/__init__.py", line 11, in <module>
    from .common.connection import HTTPConnection
  File "/home/vscode/.local/lib/python3.10/site-packages/hyper/common/connection.py", line 9, in <module>
    from ..http11.connection import HTTP11Connection
  File "/home/vscode/.local/lib/python3.10/site-packages/hyper/http11/connection.py", line 13, in <module>
    from collections import Iterable, Mapping
ImportError: cannot import name 'Iterable' from 'collections' (/usr/local/lib/python3.10/collections/__init__.py)

This is due to hyper, for stream function (http/2)

from hyper import HTTP20Connection

self.conn = HTTP20Connection(

"This project is no longer maintained!
Please use an alternative, such as HTTPX or others.
We will not publish further updates for hyper."

https://github.com/python-hyper/hyper

(faunadb-python works with python 3.9)

@tigerrabbit
Copy link

Probably not recommended, but here is a workaround I used to get fauna working on my dev (not production) script. Commented out line 12 from the file ..REDACTED/site-packages/faunadb/streams. #from hyper import HTTP20Connection. Probably will impact other functions, but did make it past the error with collections so far.

@robertcsapo
Copy link
Contributor Author

I've replaced hyper with httpx in my fork and it seems to work.

doc = client.query(q.get(q.ref(q.collection("customers"), "101")))

indexes = client.query(q.paginate(q.indexes()))
options = {"fields": ["document", "diff", "action"]}
stream = client.stream(doc["ref"], options, on_start, on_error, on_version)
stream.start()
@robertcsapo ➜ /workspaces/faunadb-python (httpx ✗) $ python example.py 
started stream at 1642450065838000
on_version event at 1642450066010000
Event action: update
Changes made: None

on_version event at 1642450080180000
Event action: update
Changes made: {'lastName': 'GitHub'}

https://github.com/robertcsapo/faunadb-python/commit/a3caa9ab3afdef664a14113943c538f381506ba5#diff-835dd880822e3220bdae3adb6dfc4385cf7e2fc783eb2e2d7ddfa0f3e31566fd

https://github.com/robertcsapo/faunadb-python/blob/httpx/faunadb/streams/client.py

@tweedge
Copy link

tweedge commented Jun 25, 2022

Just adding another comment here as Python 3.10 is shipping in more distros, and FaunaDB is the last dependency in several projects of mine to support it...

@twobitunicorn
Copy link

For those who need this to work until it gets supported. you can add the following before your fauna imports

import collections.abc
collections.Iterable = collections.abc.Iterable
collections.Mapping = collections.abc.Mapping
collections.MutableSet = collections.abc.MutableSet
collections.MutableMapping = collections.abc.MutableMapping

@mwilde345
Copy link
Member

mwilde345 commented Mar 1, 2023

Thanks @robertcsapo for the contribution 👏 , apologies all for the delay on official support. It's been added in 4.5.0

Let us know if any issues are encountered during usage.

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

No branches or pull requests

5 participants