Skip to content

Install dataclasses only on Python <3.7? #6

Closed

Description

I think there is an issue with the dataclasses library and Python 3.8.

I'm trying to use CVEdb from within a Lambda and this is the stacktrace I'm seeing:

[ERROR] AttributeError: module 'typing' has no attribute '_ClassVar'
Traceback (most recent call last):
  File "/var/lang/lib/python3.8/imp.py", line 234, in load_module
    return load_source(name, filename, file)
  File "/var/lang/lib/python3.8/imp.py", line 171, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 702, in _load
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/var/task/lambda_handler.py", line 9, in <module>
    from cvedb.db import CVEdb
  File "/opt/python/cvedb/__init__.py", line 13, in <module>
    module = import_module(f"{__name__}.{module_name}")
  File "/var/lang/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/opt/python/cvedb/cli.py", line 8, in <module>
    from .cpe import Logical
  File "/opt/python/cvedb/cpe.py", line 152, in <module>
    class CPE(Testable):
  File "/opt/python/dataclasses.py", line 950, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)
  File "/opt/python/dataclasses.py", line 800, in _process_class
    cls_fields = [_get_field(cls, name, type)
  File "/opt/python/dataclasses.py", line 800, in <listcomp>
    cls_fields = [_get_field(cls, name, type)
  File "/opt/python/dataclasses.py", line 659, in _get_field
    if (_is_classvar(a_type, typing)
  File "/opt/python/dataclasses.py", line 550, in _is_classvar
    return type(a_type) is typing._ClassVar

Looks like this is impacting a few projects:

Is there anyway to only install dataclasses with Python <3.7 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions