Python Api Flask Not Working - AttributeError: module 'typing' has no attribute '_ClassVar'

Problem description:

Hi guys Api Flask is not working at all in Replit. I created a simple demo project and is crashing.

You can check this here: https://replit.com/@fioritonicolas/OblongColorfulBash

Expected behavior:

Use ApiFlask, run and work

Actual behavior:

Install ApiFlask and see the project crash

Error:

Traceback (most recent call last):
File “main.py”, line 1, in
from apiflask import APIFlask, jsonify
File “/home/runner/OblongColorfulBash/venv/lib/python3.10/site-packages/apiflask/init.py”, line 1, in
from . import fields as fields
File “/home/runner/OblongColorfulBash/venv/lib/python3.10/site-packages/apiflask/fields.py”, line 6, in
from flask_marshmallow.fields import AbsoluteURLFor as AbsoluteURLFor
File “/home/runner/OblongColorfulBash/venv/lib/python3.10/site-packages/flask_marshmallow/init.py”, line 13, in
from . import fields
File “/home/runner/OblongColorfulBash/venv/lib/python3.10/site-packages/flask_marshmallow/fields.py”, line 12, in
from flask import url_for
File “/home/runner/OblongColorfulBash/venv/lib/python3.10/site-packages/flask/init.py”, line 4, in
from . import json as json
File “/home/runner/OblongColorfulBash/venv/lib/python3.10/site-packages/flask/json/init.py”, line 8, in
from …globals import current_app
File “/home/runner/OblongColorfulBash/venv/lib/python3.10/site-packages/flask/globals.py”, line 4, in
from werkzeug.local import LocalProxy
File “/home/runner/OblongColorfulBash/venv/lib/python3.10/site-packages/werkzeug/init.py”, line 2, in
from .test import Client as Client
File “/home/runner/OblongColorfulBash/venv/lib/python3.10/site-packages/werkzeug/test.py”, line 29, in
from .sansio.multipart import Data
File “/home/runner/OblongColorfulBash/venv/lib/python3.10/site-packages/werkzeug/sansio/multipart.py”, line 22, in
class Preamble(Event):
File “/home/runner/OblongColorfulBash/venv/lib/python3.10/site-packages/dataclasses.py”, line 950, in wrap
return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)
File “/home/runner/OblongColorfulBash/venv/lib/python3.10/site-packages/dataclasses.py”, line 800, in _process_class
cls_fields = [_get_field(cls, name, type)
File “/home/runner/OblongColorfulBash/venv/lib/python3.10/site-packages/dataclasses.py”, line 800, in
cls_fields = [_get_field(cls, name, type)
File “/home/runner/OblongColorfulBash/venv/lib/python3.10/site-packages/dataclasses.py”, line 659, in _get_field
if (_is_classvar(a_type, typing)
File “/home/runner/OblongColorfulBash/venv/lib/python3.10/site-packages/dataclasses.py”, line 550, in _is_classvar
return type(a_type) is typing._ClassVar
AttributeError: module ‘typing’ has no attribute ‘_ClassVar’. Did you mean: ‘ClassVar’?

1 Like

After looking at your code and the error (even when forked), I agree this is a bug. The code doesn’t even use this module, just import it, and it crashes. There seems to be a bug in the module.

run in Shell

pip uninstall dataclasses

And make sure you aren’t using any python 3.6 packages that depend on dataclasses

Their repl appears to be using 3.10, how’s 3.6 related?