Skip to content

AttributeError on Debug Run with PyTest #1951

Description

Environment data

  • debugpy version: 1.8.16
  • OS and version: Ubuntu 20.04.6 LTS
  • Python version: 3.12.3
  • Using VS Code or Visual Studio: VS Code

Actual behavior

collecting ... Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/jp/.pyenv/versions/3.12.3/envs/dev/lib/python3.12/site-packages/debugpy/adapter/__main__.py", line 229, in <module>
    __import__("debugpy")
  File "/home/jp/.pyenv/versions/3.12.3/envs/dev/lib/python3.12/site-packages/debugpy/adapter/../../debugpy/__init__.py", line 36, in <module>
    from debugpy.public_api import *  # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jp/.pyenv/versions/3.12.3/envs/dev/lib/python3.12/site-packages/debugpy/adapter/../../debugpy/public_api.py", line 25, in <module>
    @dataclasses.dataclass(frozen=True)
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jp/.pyenv/versions/3.12.3/envs/dev/lib/python3.12/site-packages/debugpy/adapter/../../dataclasses.py", line 950, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jp/.pyenv/versions/3.12.3/envs/dev/lib/python3.12/site-packages/debugpy/adapter/../../dataclasses.py", line 800, in _process_class
    cls_fields = [_get_field(cls, name, type)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jp/.pyenv/versions/3.12.3/envs/dev/lib/python3.12/site-packages/debugpy/adapter/../../dataclasses.py", line 659, in _get_field
    if (_is_classvar(a_type, typing)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jp/.pyenv/versions/3.12.3/envs/dev/lib/python3.12/site-packages/debugpy/adapter/../../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'?

Expected behavior

PyTest collects test(s), macro in code waits for connection from VS Code, debugging proceeds.

Steps to reproduce:

Use debugpy version 1.8.16 (downgrading to 1.8.15 fixed the problem), run a pytest for code that contains the debugpy code macro as I have below and wait a few seconds. The traceback will be reported and the wait_for_client() call will time out.

import debugpy
debugpy.listen(5679)
debugpy.wait_for_client()

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions