Commit c672979
Modernize ddev create check template (DataDog#23705)
* Modernize ddev create check template to Python 3.13 idioms
- Replace Python 2-style super() call with bare super().__init__()
- Replace PEP 484 comment-form type annotations with inline annotations
- Add typed signatures to check() and __init__() using InitConfigType and
InstanceType from datadog_checks.base.types
- Type conftest fixtures (Iterator[None], InstanceType)
- Remove noqa: F401 markers that existed only to support comment annotations
- Use dict[str, Any] instead of Dict[str, Any] in test_unit.py
* Add changelog entry for PR DataDog#23705
* Shorter changelog
* Add ConfigMixin and bump datadog-checks-base version in template
* Enable mypy in check template via hatch check-types
Enable check-types in hatch.toml so mypy runs as part of ddev test --lint
on every new integration generated from the check template. Add
--explicit-package-bases to handle the namespace package layout under
datadog_checks/.
Fix the dd_run_check fixture annotation in test_unit.py from
Callable[[AgentCheck, bool], None] (which lied about the signature and
was previously hidden inside a PEP 484 comment) to Callable[..., None],
matching the actual fixture signature run_check(check, extract_message=
False, cancel=True).
* Add test_e2e template and teaching comments for tests
Add tests/test_e2e.py to the check template so new integrations ship
with an end-to-end test from day one. The stub is gated by
@pytest.mark.e2e so it does not run under `ddev test`, only under
`ddev env test`. Live assertions cover the metadata sanity checks
(assert_metrics_using_metadata + assert_all_metrics_covered); a
commented block lists the common per-metric, per-tag and service-check
assertions.
Expand tests/test_unit.py with the same teaching-comment pattern
already used in check.py: a commented menu of assert_metric,
assert_metric_has_tag, assert_metric_has_tag_prefix and
assert_service_check.
Add a commented docker_run + CheckEndpoints example to dd_environment
in tests/conftest.py so users see the canonical setup pattern without
shipping an empty docker/ folder, which would be misleading given how
divergent real integration setups are.
* Delete servicechecks comment
* Use find_free_port in conftest docker_run example
Address review feedback: replace the hardcoded port 1234 in the
commented dd_environment example with find_free_port(get_docker_hostname()),
so users following the pattern do not collide with whatever happens to
be listening on their host.
* Move self.config to check() and rename changelog
* Change comment
* Fix README template to align with current capitalization
* Capitalize 'Checks'
Co-authored-by: Ursula Chen <58821586+urseberry@users.noreply.github.com>
* Capitalize 'Collected'
Co-authored-by: Ursula Chen <58821586+urseberry@users.noreply.github.com>
* Remove --explicit-package-bases from hatch.toml template
* Capitalize Collected
Co-authored-by: Ursula Chen <58821586+urseberry@users.noreply.github.com>
* Capitalize Checks
Co-authored-by: Ursula Chen <58821586+urseberry@users.noreply.github.com>
---------
Co-authored-by: Ursula Chen <58821586+urseberry@users.noreply.github.com>1 parent 656fac7 commit c672979
8 files changed
Lines changed: 99 additions & 29 deletions
File tree
- datadog_checks_dev
- changelog.d
- datadog_checks/dev/tooling/templates/integration/check/{check_name}
- datadog_checks/{check_name}
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
Lines changed: 17 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
11 | | - | |
12 | | - | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
| 17 | + | |
| 18 | + | |
21 | 19 | | |
22 | 20 | | |
23 | 21 | | |
| |||
32 | 30 | | |
33 | 31 | | |
34 | 32 | | |
35 | | - | |
36 | | - | |
| 33 | + | |
37 | 34 | | |
38 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | | - | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
46 | | - | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | | - | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | | - | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
63 | | - | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
Lines changed: 24 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
2 | 4 | | |
3 | 5 | | |
| 6 | + | |
| 7 | + | |
4 | 8 | | |
5 | 9 | | |
6 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
7 | 29 | | |
8 | 30 | | |
9 | 31 | | |
10 | 32 | | |
11 | | - | |
| 33 | + | |
12 | 34 | | |
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
Lines changed: 26 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | | - | |
6 | | - | |
| 5 | + | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
16 | | - | |
| 19 | + | |
| 20 | + | |
17 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
0 commit comments