Django (5.2.4) fails to setup with `anyio==4.12.0`

After upgrading anyio from 4.11.0 to 4.12.0 in my Django project, the application fails to setup as below:

Traceback (most recent call last):
  File "/home/runner/work/application/repo/manage.py", line 31, in <module>
    execute_from_command_line(sys.argv)
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.13.7/x64/lib/python3.13/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
    ~~~~~~~~~~~~~~~^^
  File "/opt/hostedtoolcache/Python/3.13.7/x64/lib/python3.13/site-packages/django/core/management/__init__.py", line 416, in execute
    django.setup()
    ~~~~~~~~~~~~^^
  File "/opt/hostedtoolcache/Python/3.13.7/x64/lib/python3.13/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.13.7/x64/lib/python3.13/site-packages/django/apps/registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
  File "/opt/hostedtoolcache/Python/3.13.7/x64/lib/python3.13/site-packages/django/apps/config.py", line 197, in create
    if not issubclass(app_config_class, AppConfig):
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: issubclass() arg 1 must be a class

The project depends on django==5.2.4, celery==5.4.0, django-celery-beat==2.8.1, and other packages, but I’m not yet sure which dependency is pulling in anyio.

Pinning anyio==4.11.0 resolves the issue temporarily, and I’m currently investigating the source of the dependency.

In my case, anyio was pulled in by valkey-glide, openai, and watchfiles.

Can you edit this file:

to add a breakpoint() call or print(entry) and see which app causes the issue?

1 Like

The first arg of issubclass in the traceback is the AppConfig class – that is typically a class defined in apps.py in your app. I’m guessing that you’re doing something nonstandard there, that indeed depends on anyio.

1 Like

Both of you thanks a lot! I will take a try and get back soon :slight_smile: