Persistent Import Errors in VS Code Debugging for Custom Integration - how to setup dev containers?

I’m attempting to develop a custom integration following the guidelines in the Set up development environment | Home Assistant Developer Docs. My setup involves a Proxmox VM running Home Assistant Core in a Docker container (ha-dev-container), with files in /home/docker/ha_dev/core/config/custom_components//. I’m using VS Code with Remote-SSH and the Remote - Containers extension to edit and debug the code.

I’m encountering persistent import errors in VS Code: Import "voluptuous" could not be resolved and Import "homeassistant" could not be resolved, which appear in the Problems panel when opening config_flow.py. These errors prevent effective debugging, as breakpoints aren’t hit reliably. My goal is to set up live debugging to step through my integration’s config_flow.py.

Steps I’ve taken to resolve this include:

  • Installed Docker and Docker Compose on the VM, cloned the Home Assistant Core repository, and built the container using docker-compose as per the documentation.

  • Set up VS Code with Remote-SSH, mounted the config directory (/home/docker/ha_dev/core/config:/config), and installed the Python extension.

  • Selected the container’s Python interpreter (/usr/local/bin/python3) and reloaded VS Code, which cleared the errors briefly but not consistently.

  • Installed the Docker and Remote - Containers extensions, attached to the container, and reinstalled the Python extension inside the container.

  • Installed debugpy (version 1.8.13) in the container with pip3 install debugpy and ran python3 -Xfrozen_modules=off -m debugpy --listen 0.0.0.0:5678 --wait-for-client /usr/local/bin/hass --config /config --debug.

  • Configured launch.json with "request": "attach", "host" "port": 5678, reloaded the window, and attempted to debug, but the errors persist.

I’ve also copied requirements_all.txt to /tmp/requirements.txt in the container and run pip3 install -r /tmp/requirements.txt (after removing a recursive reference), with no errors in the configuration check (hass --script check_config -c /config). Despite this, the import errors remain during debugging.

Could anyone advise on how to resolve these import errors in VS Code’s debugging environment for a containerized Home Assistant setup? Are there specific settings or additional steps in the development environment documentation that I’ve missed? Any insights into configuring the Python extension or debugpy for this scenario would be greatly appreciated!