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

API change for collections in Python 3.3+ breaks is_atomic in options.py #352

Open
whudson opened this issue Apr 13, 2022 · 5 comments
Open

Comments

@whudson
Copy link

whudson commented Apr 13, 2022

Running in Python 3.10 and calling gmaps.symbol_layer() with info_boxes set to a list of strings:

File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\gmaps\options.py:40, in is_atomic(elem)
     34 def is_atomic(elem):
     35     """
     36     True if an element is a single atom and false if it's a collection
     37     """
     38     return (
     39         isinstance(elem, string_types) or
---> 40         not isinstance(elem, collections.Iterable)
     41     )

AttributeError: module 'collections' has no attribute 'Iterable'

In python 3.3+ these are moved into the collections.abc (abstract base classes) module. For some reason I have to access them like this when testing in my code:

import _collections_abc
_collections_abc.Iterable
@whudson whudson closed this as completed Apr 13, 2022
@whudson
Copy link
Author

whudson commented Apr 13, 2022

Sorry I'm getting myself confused here. Creating a layer with one argument works, but adding additional options fails at the is_atomic function. I'll try to send a PR for this later.

@whudson whudson reopened this Apr 13, 2022
@whudson
Copy link
Author

whudson commented Apr 14, 2022

Apparently the correct way to do it is one of:

from collections.abc import *
from collections import abc

I'm not sure how the CI tests are passing on the existing build for v3.3+, but changing the import was definitely needed on my machine.

@timcoote
Copy link

timcoote commented Nov 9, 2022

This bug wasn't evident with Pyhton 3.9, but it is with 3.10.

@whudson
Copy link
Author

whudson commented Apr 6, 2023

I'm not sure how to fix this in a good way - I'll leave it up to someone else.

@madappally
Copy link

As a temporary workaround, add these lines in your script.

import collections
collections.Iterable = collections.abc.Iterable

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

3 participants