Skip to content

Commit 4ce8028

Browse files
committed
Merge branch 'main' of https://github.com/microsoft/debugpy into rchiodo/type_standard
# Conflicts: # CONTRIBUTING.md # src/debugpy/adapter/clients.py # src/debugpy/adapter/launchers.py # src/debugpy/adapter/servers.py # src/debugpy/common/sockets.py # src/debugpy/server/api.py # src/debugpy/server/cli.py # tests/requirements.txt
2 parents 9c7c06b + cd699b4 commit 4ce8028

655 files changed

Lines changed: 165890 additions & 78534 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/skills/click/SKILL.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
name: click
3+
description: Best practices for building CLI applications with Click including commands, groups, options, and testing.
4+
---
5+
6+
# Skill: Click
7+
8+
Best practices for building CLI applications with Click including commands, groups, options, and testing.
9+
10+
## When to Use
11+
12+
Apply this skill when building command-line interfaces with Click — commands, groups, options, arguments, and prompts.
13+
14+
## Commands
15+
16+
- Use `@click.command()` for single commands, `@click.group()` for multi-command CLIs.
17+
- Declare options with `@click.option()` and positional args with `@click.argument()`.
18+
- Use `help=` on every option and command for auto-generated help text.
19+
- Use `envvar=` to allow environment variable fallback for sensitive options.
20+
21+
## Groups
22+
23+
- Organize subcommands with `@click.group()` and `group.add_command()`.
24+
- Use `@click.pass_context` to share state between group and subcommands.
25+
26+
## Type Safety
27+
28+
- Use Click's built-in types (`click.Path(exists=True)`, `click.Choice([...])`, `click.IntRange()`).
29+
- Use callbacks for custom validation.
30+
31+
## Testing
32+
33+
- Use `click.testing.CliRunner()` for testing commands without subprocess overhead.
34+
- Assert on `result.exit_code` and `result.output`.
35+
- Use `mix_stderr=False` to test stderr separately.
36+
37+
## Pitfalls
38+
39+
- Don't use `sys.exit()` — use `click.exceptions.Exit` or return from the command.
40+
- Don't use `print()` — use `click.echo()` for proper encoding handling.
41+
- Always handle `KeyboardInterrupt` / abort prompts gracefully.

.claude/skills/django/SKILL.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
name: django
3+
description: Best practices for Django web development including models, views, templates, and testing.
4+
---
5+
6+
# Skill: Django
7+
8+
Best practices for Django web development including models, views, templates, and testing.
9+
10+
## When to Use
11+
12+
Apply this skill when working with Django projects — models, views, URL routing, templates, forms, admin, and management commands.
13+
14+
## Project Structure
15+
16+
- Follow the standard Django app layout: `models.py`, `views.py`, `urls.py`, `admin.py`, `tests.py`, `forms.py`.
17+
- Keep each app focused on a single domain concept; avoid "god apps" with unrelated models.
18+
- Use `settings/base.py`, `settings/dev.py`, `settings/prod.py` for environment-specific configuration.
19+
20+
## Models
21+
22+
- Always define `__str__` on models for admin and debugging readability.
23+
- Use `Meta.ordering` sparingly — it adds `ORDER BY` to every query. Prefer explicit `.order_by()` on querysets.
24+
- Use database indexes (`db_index=True`, `Meta.indexes`) for fields that appear in `filter()` / `order_by()`.
25+
- Prefer `CharField` with `choices` (or `TextChoices` / `IntegerChoices`) over bare strings for constrained fields.
26+
- Use `F()` expressions and `Q()` objects for complex queries to avoid race conditions and improve readability.
27+
28+
## Views
29+
30+
- Prefer class-based views (CBVs) for CRUD; prefer function-based views for one-off logic.
31+
- Always explicitly set `queryset` or override `get_queryset()` — never rely on mutable class-level state.
32+
- Use `select_related()` and `prefetch_related()` to avoid N+1 query problems.
33+
- Set `LOGIN_URL` and use `@login_required` / `LoginRequiredMixin` consistently.
34+
35+
## Testing
36+
37+
- Use `pytest-django` with `@pytest.mark.django_db` for database access.
38+
- Prefer `TestCase` or `TransactionTestCase` only when explicit transaction control is needed; otherwise use pytest fixtures.
39+
- Use `RequestFactory` or `Client` to test views without starting a server.
40+
- Use `baker.make()` (model-bakery) or factories instead of manual model construction in tests.
41+
42+
## Pitfalls
43+
44+
- Never do blocking I/O in async views without wrapping in `sync_to_async`.
45+
- Avoid importing models at module level in `settings.py` or `urls.py` (circular imports).
46+
- Never store secrets in `settings.py` — use environment variables.
47+
- Avoid raw SQL unless the ORM genuinely cannot express the query.

.claude/skills/flask/SKILL.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
name: flask
3+
description: Best practices for Flask web development including routing, blueprints, and testing.
4+
---
5+
6+
# Skill: Flask
7+
8+
Best practices for Flask web development including routing, blueprints, and testing.
9+
10+
## When to Use
11+
12+
Apply this skill when building Flask web applications or APIs — routing, blueprints, extensions, and testing.
13+
14+
## Project Structure
15+
16+
- Use the application factory pattern (`create_app()`) to avoid global state and enable testing.
17+
- Organize features into Blueprints; register them in the factory.
18+
- Keep configuration in a `config.py` with classes like `DevelopmentConfig`, `ProductionConfig`.
19+
20+
## Routing and Views
21+
22+
- Prefer explicit HTTP method decorators (`@app.get`, `@app.post`) over generic `@app.route` with `methods=[...]`.
23+
- Validate request data early; return 400 errors for malformed input before processing.
24+
- Use `flask.abort()` with appropriate HTTP codes rather than returning error responses manually.
25+
26+
## Extensions
27+
28+
- Initialize extensions lazily with `ext.init_app(app)` inside the factory, not at module level.
29+
- Common extensions: Flask-SQLAlchemy, Flask-Migrate, Flask-Login, Flask-WTF, Flask-CORS.
30+
31+
## Testing
32+
33+
- Use `app.test_client()` for HTTP-level tests and `app.test_request_context()` for unit tests.
34+
- Use pytest fixtures to create the app and client; scope appropriately (`session` for the app, `function` for the client).
35+
- Set `TESTING=True` and use a separate test database.
36+
37+
## Pitfalls
38+
39+
- Never use the development server (`app.run()`) in production — use Gunicorn or uWSGI.
40+
- Avoid storing mutable state on the `app` object; use `g` for request-scoped data.
41+
- Never hardcode `SECRET_KEY` — load from environment variables.

.claude/skills/jinja2/SKILL.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
name: jinja2
3+
description: Best practices for template rendering with Jinja2 including environments, filters, autoescaping, and security.
4+
---
5+
6+
# Skill: Jinja2
7+
8+
Best practices for template rendering with Jinja2 including environments, filters, autoescaping, and security.
9+
10+
## When to Use
11+
12+
Apply this skill when rendering templates with Jinja2 — HTML pages, emails, configuration files, and code generation.
13+
14+
## Environment
15+
16+
- Create a `jinja2.Environment(loader=..., autoescape=...)` once and reuse it.
17+
- Use `FileSystemLoader` for file-based templates, `PackageLoader` for installed packages.
18+
- Enable `autoescape=True` for HTML templates to prevent XSS.
19+
20+
## Templates
21+
22+
- Use `{{ variable }}` for output, `{% if/for/block %}` for control flow.
23+
- Use template inheritance (`{% extends 'base.html' %}`) for layout reuse.
24+
- Define custom filters for reusable transformations.
25+
26+
## Security
27+
28+
- **Always** enable `autoescape=True` when rendering HTML.
29+
- Use `SandboxedEnvironment` for untrusted templates.
30+
- Never render user input as template code — only as template data.
31+
- Use `|e` filter explicitly when autoescape is off.
32+
33+
## Pitfalls
34+
35+
- Don't use `Template(string)` directly — it bypasses the environment's loader and settings.
36+
- Watch for undefined variable errors — use `undefined=StrictUndefined` during development.
37+
- Avoid complex logic in templates — keep them focused on presentation.

.claude/skills/numpy/SKILL.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
name: numpy
3+
description: Best practices for numerical computing with NumPy including arrays, broadcasting, and vectorization.
4+
---
5+
6+
# Skill: NumPy
7+
8+
Best practices for numerical computing with NumPy including arrays, broadcasting, and vectorization.
9+
10+
## When to Use
11+
12+
Apply this skill when doing numerical computing with NumPy — arrays, broadcasting, linear algebra, random sampling.
13+
14+
## Arrays
15+
16+
- Use explicit dtypes (`np.float64`, `np.int32`) when creating arrays.
17+
- Prefer `np.zeros`, `np.ones`, `np.empty`, `np.arange`, `np.linspace` over list-based construction.
18+
- Use structured arrays or separate arrays instead of object arrays.
19+
20+
## Vectorization
21+
22+
- Replace Python loops with vectorized NumPy operations wherever possible.
23+
- Use broadcasting rules to operate on arrays of different shapes without explicit expansion.
24+
- Use `np.where()` for conditional element-wise operations.
25+
26+
## Memory
27+
28+
- Use `np.float32` instead of `np.float64` when precision is not critical to halve memory.
29+
- Use views (`reshape`, slicing) instead of copies when data doesn't need mutation.
30+
- Use `np.memmap` for arrays too large to fit in RAM.
31+
32+
## Random
33+
34+
- Use `np.random.default_rng(seed)` (new Generator API) instead of `np.random.seed()`.
35+
- Always seed random generators in tests for reproducibility.
36+
37+
## Pitfalls
38+
39+
- Don't compare floats with `==`; use `np.allclose()` or `np.isclose()`.
40+
- Beware of silent integer overflow in integer arrays.
41+
- Avoid `np.matrix` — it's deprecated; use 2D `np.ndarray`.

.claude/skills/pytest/SKILL.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
name: pytest
3+
description: Best practices for writing and organizing tests with pytest including fixtures, parametrize, and plugins.
4+
---
5+
6+
# Skill: pytest
7+
8+
Best practices for writing and organizing tests with pytest including fixtures, parametrize, and plugins.
9+
10+
## When to Use
11+
12+
Apply this skill when writing and organizing tests with pytest — fixtures, parametrize, markers, plugins, and test structure.
13+
14+
## Test Organization
15+
16+
- Place tests in a `tests/` directory mirroring the source structure.
17+
- Name test files `test_<module>.py` and test functions `test_<behavior>()`.
18+
- Group related tests in classes only when they share fixtures/setup.
19+
20+
## Fixtures
21+
22+
- Define fixtures at the narrowest scope needed (`function` > `class` > `module` > `session`).
23+
- Use `conftest.py` for shared fixtures; put it at the appropriate directory level.
24+
- Prefer factory fixtures over complex fixture inheritance.
25+
- Use `yield` fixtures for setup/teardown; prefer `tmp_path` over `tempfile`.
26+
27+
## Parametrize
28+
29+
- Use `@pytest.mark.parametrize` for data-driven tests with multiple inputs.
30+
- Give test IDs (`ids=...`) for readable test output.
31+
- Combine `parametrize` with fixtures for cross-product testing.
32+
33+
## Assertions
34+
35+
- Use plain `assert` statements — pytest rewrites them for clear failure messages.
36+
- Use `pytest.raises(ExceptionType, match=...)` for exception testing.
37+
- Use `pytest.approx()` for floating-point comparisons.
38+
39+
## Plugins
40+
41+
- Common plugins: `pytest-cov`, `pytest-mock`, `pytest-asyncio`, `pytest-xdist`, `pytest-timeout`.
42+
- Use `pytest-mock`'s `mocker` fixture over raw `unittest.mock.patch`.
43+
44+
## Pitfalls
45+
46+
- Don't use `session`-scoped fixtures for mutable state.
47+
- Don't assert on implementation details — test observable behavior.
48+
- Avoid test interdependence; each test should be runnable in isolation.

.claude/skills/requests/SKILL.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
name: requests
3+
description: Best practices for HTTP client usage with Requests including sessions, error handling, and timeouts.
4+
---
5+
6+
# Skill: Requests
7+
8+
Best practices for HTTP client usage with Requests including sessions, error handling, and timeouts.
9+
10+
## When to Use
11+
12+
Apply this skill when making HTTP requests with the Requests library — sessions, auth, error handling, retries, and file uploads.
13+
14+
## Sessions
15+
16+
- Use `requests.Session()` for connection pooling and persistent headers/cookies across multiple requests.
17+
- Configure `session.headers` for default auth tokens and user-agent strings.
18+
- Use `session.mount()` with `HTTPAdapter` for retry logic.
19+
20+
## Error Handling
21+
22+
- Always call `response.raise_for_status()` to surface HTTP errors as exceptions.
23+
- Always set `timeout=(connect_timeout, read_timeout)` — never use infinite timeouts.
24+
- Handle `requests.ConnectionError`, `requests.Timeout`, and `requests.HTTPError` explicitly.
25+
26+
## Retries
27+
28+
- Use `urllib3.util.Retry` with `HTTPAdapter` for automatic retries with backoff.
29+
- Configure status-based retries for transient errors (429, 500, 502, 503, 504).
30+
31+
## Security
32+
33+
- Never disable SSL verification (`verify=False`) in production.
34+
- Pass credentials via environment variables, not hardcoded strings.
35+
- Use `auth=` parameter for HTTP auth rather than manually setting headers.
36+
37+
## Pitfalls
38+
39+
- Don't forget timeouts — they default to None (infinite wait).
40+
- Don't use `requests.get()` for high-throughput — use sessions.
41+
- Close responses from streaming requests (`stream=True`) to release connections.

.devcontainer/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM mcr.microsoft.com/devcontainers/python:3.14
2+
3+
# Install GDB
4+
RUN apt-get update && \
5+
apt-get install -y --no-install-recommends gdb \
6+
&& apt-get clean \
7+
&& rm -rf /var/lib/apt/lists/*
8+
9+
# Switch to non-root user and install Python packages
10+
USER vscode
11+
RUN python -m pip install black flake8 tox

.devcontainer/devcontainer.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "debugpy Development",
3+
"build": {
4+
"dockerfile": "Dockerfile"
5+
},
6+
7+
"features": {
8+
"ghcr.io/devcontainers/features/git:1": {}
9+
},
10+
11+
"remoteUser": "vscode"
12+
}

.gdn/.gdnsuppress

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"hydrated": true,
3+
"properties": {
4+
"helpUri": "https://eng.ms/docs/microsoft-security/security/azure-security/cloudai-security-fundamentals-engineering/security-integration/guardian-wiki/microsoft-guardian/general/suppressions"
5+
},
6+
"version": "1.0.0",
7+
"suppressionSets": {
8+
"default": {
9+
"name": "default",
10+
"createdDate": "2026-01-28 00:33:53Z",
11+
"lastUpdatedDate": "2026-01-28 00:33:53Z"
12+
}
13+
},
14+
"results": {
15+
"58a87fd4d7371ece41c06d9d8ef960a90be375cf25621fdddc0f69ed70a8b6f4": {
16+
"signature": "58a87fd4d7371ece41c06d9d8ef960a90be375cf25621fdddc0f69ed70a8b6f4",
17+
"alternativeSignatures": [
18+
"86f6ccbed316821fbcca7e2f0daafcc164b6df645a491d850e1ac16b39eb747e"
19+
],
20+
"target": "pydevd/inject_dll_amd64.exe",
21+
"memberOf": [
22+
"default"
23+
],
24+
"tool": "binskim",
25+
"ruleId": "BA2007",
26+
"createdDate": "2026-01-28 00:33:53Z"
27+
},
28+
"2b82071ec3bb1a8e80b1615d79febb69084008a4b5a19e66dbeac590b39d4c55": {
29+
"signature": "2b82071ec3bb1a8e80b1615d79febb69084008a4b5a19e66dbeac590b39d4c55",
30+
"alternativeSignatures": [
31+
"3e5a1d789a42983ae1541ba91e20f10f388886a5ba62833ec66e0a358adc1174"
32+
],
33+
"target": "pydevd/inject_dll_x86.exe",
34+
"memberOf": [
35+
"default"
36+
],
37+
"tool": "binskim",
38+
"ruleId": "BA2007",
39+
"createdDate": "2026-01-28 00:33:53Z"
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)