Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

AttributeError on Debug Run with PyTest

Open
#1,951 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python

Research direction

Start by reproducing the pytest run with debugpy 1.8.16 and comparing it with 1.8.15. Read debugpy/adapter/main.py, debugpy/public_api.py, and the bundled dataclasses.py around the reported _ClassVar lookup; done means collection completes and wait_for_client() no longer times out under the reported environment.

Written by the indexing model from the issue text.

Description

user responded

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()
Dominant language
Python
Stars
2.5k
Forks
202
Avg merge
5d 1h
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/debugpy

All issues in microsoft/debugpy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.