.. index:: vscode project structure ide .. _`sec:ide`: Coding environment ================== Prerequisite ------------ Install on your machine ``VSCode``, probably the most popular Integrated Development Environment (IDE). See `download `_ and `docs `_. Configuration ------------- Must have extensions: ``python, ruff`` Recommended extensions: ``python debugger, even better toml, better comments, code spell checker, autodocstring python, git history`` Change save on focus and enable standard type check in settings (type hints will be covered in more detail in a future session). .. Structure .. --------- .. In a ``PROJECT`` folder: .. Create a ``src/`` folder and move ``FILE.py`` there. .. Add a ``__init__.py`` in folders under ``src/`` to create a package or subpackage. .. Create a ``tests/`` folder. .. To avoid imports issues, add ``.vscode/`` folder and add a ``settings.json`` there with .. .. code-block:: json .. { .. "python.analysis.extraPaths": [ .. "./src", .. ".venv/lib/python3.13/site-packages" .. ] .. } .. To guide ``pytest`` to the source folder add, in ``pyproject.toml``. .. .. code-block:: toml [tool.pytest.ini_options] .. pythonpath = "src" Basic usage ----------- Demo .. code-block:: python # panels, split # Write a function, a unit test, run the test. # Rename a variable inside a function. # Multiple selection # Panels # Rename a function (and see change propagating to the test file) # Go to a function definition from test # Type error based on type hints. # Refactor (extract).