ForestAdmin / django-forestadmin

🐍 Django agent for Forest Admin to integrate directly to your existing Django backend application.
https://www.forestadmin.com
GNU General Public License v3.0
123 stars 18 forks source link

Python 3.10: ImportError: cannot import name 'Mapping' from 'collections' #72

Closed chmod77 closed 2 years ago

chmod77 commented 2 years ago

Expected behavior

Running ./manage.py runserver should not result in any errors.

Actual behavior

Testing django_forest on Django 4.0b1 and Python 3.10 results in an import error: ImportError: cannot import name 'Mapping' from 'collections'

PS: This is most likely stemming from the oic library. Changing the import in question to from collections.abc import Mapping will work on Python 3.10

Failure Logs

> ./manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.10/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 1009, in _bootstrap_inner
    self.run()
  File "/usr/local/Cellar/python@3.10/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 946, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/<USER>/.local/share/virtualenvs/<project>-aqsNCo9p/lib/python3.10/site-packages/django/utils/autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "/Users/<USER>/.local/share/virtualenvs/<project>-aqsNCo9p/lib/python3.10/site-packages/django/core/management/commands/runserver.py", line 124, in inner_run
    self.check(display_num_errors=True)
  File "/Users/<USER>/.local/share/virtualenvs/<project>-aqsNCo9p/lib/python3.10/site-packages/django/core/management/base.py", line 438, in check
    all_issues = checks.run_checks(
  File "/Users/<USER>/.local/share/virtualenvs/<project>-aqsNCo9p/lib/python3.10/site-packages/django/core/checks/registry.py", line 77, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "/Users/<USER>/.local/share/virtualenvs/<project>-aqsNCo9p/lib/python3.10/site-packages/django/core/checks/urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "/Users/<USER>/.local/share/virtualenvs/<project>-aqsNCo9p/lib/python3.10/site-packages/django/core/checks/urls.py", line 23, in check_resolver
    return check_method()
  File "/Users/<USER>/.local/share/virtualenvs/<project>-aqsNCo9p/lib/python3.10/site-packages/django/urls/resolvers.py", line 442, in check
    for pattern in self.url_patterns:
  File "/Users/<USER>/.local/share/virtualenvs/<project>-aqsNCo9p/lib/python3.10/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/Users/<USER>/.local/share/virtualenvs/<project>-aqsNCo9p/lib/python3.10/site-packages/django/urls/resolvers.py", line 628, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/Users/<USER>/.local/share/virtualenvs/<project>-aqsNCo9p/lib/python3.10/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/Users/<USER>/.local/share/virtualenvs/<project>-aqsNCo9p/lib/python3.10/site-packages/django/urls/resolvers.py", line 621, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/local/Cellar/python@3.10/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/<USER>/Projects/ian/<project>/src/tapin/urls.py", line 24, in <module>
    path('forest', include('django_forest.urls')),
  File "/Users/<USER>/.local/share/virtualenvs/<project>-aqsNCo9p/lib/python3.10/site-packages/django/urls/conf.py", line 34, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/local/Cellar/python@3.10/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/<USER>/.local/share/virtualenvs/<project>-aqsNCo9p/lib/python3.10/site-packages/django_forest/urls.py", line 5, in <module>
    from .authentication import urls as authentication_urls
  File "/Users/<USER>/.local/share/virtualenvs/<project>-aqsNCo9p/lib/python3.10/site-packages/django_forest/authentication/urls.py", line 4, in <module>
    from . import views
  File "/Users/<USER>/.local/share/virtualenvs/<project>-aqsNCo9p/lib/python3.10/site-packages/django_forest/authentication/views/__init__.py", line 1, in <module>
    from .callback import CallbackView
  File "/Users/<USER>/.local/share/virtualenvs/<project>-aqsNCo9p/lib/python3.10/site-packages/django_forest/authentication/views/callback.py", line 5, in <module>
    from oic.oauth2 import AuthorizationResponse
  File "/Users/<USER>/.local/share/virtualenvs/<project>-aqsNCo9p/lib/python3.10/site-packages/oic/oauth2/__init__.py", line 18, in <module>
    from oic.oauth2.base import PBase
  File "/Users/<USER>/.local/share/virtualenvs/<project>-aqsNCo9p/lib/python3.10/site-packages/oic/oauth2/base.py", line 10, in <module>
    from oic.oauth2.util import set_cookie
  File "/Users/<USER>/.local/share/virtualenvs/<project>-aqsNCo9p/lib/python3.10/site-packages/oic/oauth2/util.py", line 12, in <module>
    from oic.utils.sanitize import sanitize
  File "/Users/<USER>/.local/share/virtualenvs/<project>-aqsNCo9p/lib/python3.10/site-packages/oic/utils/sanitize.py", line 2, in <module>
    from collections import Mapping
ImportError: cannot import name 'Mapping' from 'collections' (/usr/local/Cellar/python@3.10/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/collections/__init__.py)

Context

vamonte commented 2 years ago

Python 3.10 and Django 4 are not officially supported for the moment. The support of these versions is in our pipe.

tirkarthi commented 2 years ago

This has been resolved on oic in https://github.com/OpenIDC/pyoidc/commit/deabbebb56d23016ca1fc95a7f969c128b0a6c3e

vamonte commented 2 years ago

@tirkarthi Thanks, I will check it

vamonte commented 2 years ago

@tirkarthi Do you confirm, that the issue is resolved by the last version of pyoidc ? Can I close this issue ? Thank's

chmod77 commented 2 years ago

This has been resolved on oic in https://github.com/OpenIDC/pyoidc/commit/deabbebb56d23016ca1fc95a7f969c128b0a6c3e

Checking this.