Use GitHub Copilot Chat to interactively create documentation, add type hints, and make unit tests

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 เม.ย. 2024
  • I start out with some Python code from stack overflow that is largely undocumented. I use the Autodocstring VS Code extension (marketplace.visualstudio.com/...) to create template docstrings and then ask GitHub Copilot Chat (docs.github.com/en/copilot/gi...) to fill in these templates with the correct information. After doing some manual quality checks, I then ask it to add type hints to the code. After requesting the type hints, I use it to create unit tests. Characteristic of many large language models, the code has some "hallucinations". In this case, when it populated type hints across the codebase, it tried accessing `pytest.terminal` even though the `terminal` attribute doesn't actually exist. This can be easily verified and diagnosed by running the code in debugging mode and observing the error. From here, it's possible to either manually correct the code or to feed the error message back into GitHub Copilot Chat to interactively refine the solutions. While it's not a perfect solution, when used effectively, it can dramatically reduce the amount of manual typing that's needed and streamline the development workflow.
    Note: you no longer need VS Code Insiders to be able to use GitHub Copilot Chat. The stable release of VS Code is sufficient.

ความคิดเห็น •