strawberry-graphql / strawberry

A GraphQL library for Python that leverages type annotations 🍓
https://strawberry.rocks
MIT License
4.01k stars 531 forks source link

Error when running on python 13 #3688

Closed helioascorreia closed 1 week ago

helioascorreia commented 1 week ago

I have a project running in python 12. After updating to python 13 I got the following error

root@323b676783df:/project/banks# python manage.py check
Traceback (most recent call last):
  File "/project/banks/manage.py", line 22, in <module>
    main()
    ~~~~^^
  File "/project/banks/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
    ~~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.13/site-packages/django/core/management/commands/check.py", line 76, in handle
    self.check(
    ~~~~~~~~~~^
        app_configs=app_configs,
        ^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
        databases=options["databases"],
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/django/core/management/base.py", line 485, in check
    all_issues = checks.run_checks(
        app_configs=app_configs,
    ...<2 lines>...
        databases=databases,
    )
  File "/usr/local/lib/python3.13/site-packages/django/core/checks/registry.py", line 88, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "/usr/local/lib/python3.13/site-packages/django/core/checks/urls.py", line 14, in check_url_config
    return check_resolver(resolver)
  File "/usr/local/lib/python3.13/site-packages/django/core/checks/urls.py", line 24, in check_resolver
    return check_method()
  File "/usr/local/lib/python3.13/site-packages/django/urls/resolvers.py", line 494, in check
    for pattern in self.url_patterns:
                   ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/utils/functional.py", line 57, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
                                         ~~~~~~~~~^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/urls/resolvers.py", line 715, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
                       ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/utils/functional.py", line 57, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
                                         ~~~~~~~~~^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/urls/resolvers.py", line 708, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/local/lib/python3.13/importlib/__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1022, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/project/banks/app/urls.py", line 9, in <module>
    from .schema import schema
  File "/project/banks/app/schema.py", line 1, in <module>
    import strawberry
  File "/usr/local/lib/python3.13/site-packages/strawberry/__init__.py", line 1, in <module>
    from . import experimental, federation, relay
  File "/usr/local/lib/python3.13/site-packages/strawberry/federation/__init__.py", line 5, in <module>
    from .object_type import input, interface, interface_object, type
  File "/usr/local/lib/python3.13/site-packages/strawberry/federation/object_type.py", line 16, in <module>
    from strawberry.object_type import type as base_type
  File "/usr/local/lib/python3.13/site-packages/strawberry/object_type.py", line 30, in <module>
    from .utils.dataclasses import add_custom_init_fn
  File "/usr/local/lib/python3.13/site-packages/strawberry/utils/dataclasses.py", line 13, in <module>
    from strawberry.ext.dataclasses.dataclasses import dataclass_init_fn
  File "/usr/local/lib/python3.13/site-packages/strawberry/ext/dataclasses/dataclasses.py", line 5, in <module>
    from dataclasses import (  # type: ignore
    ...<7 lines>...
    )
ImportError: cannot import name '_create_fn' from 'dataclasses' (/usr/local/lib/python3.13/dataclasses.py)

After some search I found that python13 remove the function _create_fn.

Is there any fix in the plans for this in a newer version? Or some fix that I can apply on my code?

Thanks

Upvote & Fund

Fund with Polar

patrick91 commented 1 week ago

@helioascorreia have you updated to the latest version of Strawberry? :)

helioascorreia commented 1 week ago

Damm! my bad, I only check that the requirements doesn't had the version locked by other package was blocking the version