ansible-core 2.17.6__py3-none-any.whl → 2.18.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ansible-core might be problematic. Click here for more details.

Files changed (325) hide show
  1. ansible/__main__.py +2 -17
  2. ansible/cli/__init__.py +3 -15
  3. ansible/cli/config.py +187 -24
  4. ansible/cli/console.py +1 -1
  5. ansible/cli/doc.py +38 -16
  6. ansible/cli/galaxy.py +3 -49
  7. ansible/cli/inventory.py +2 -2
  8. ansible/cli/pull.py +2 -2
  9. ansible/cli/scripts/ansible_connection_cli_stub.py +1 -10
  10. ansible/config/base.yml +127 -57
  11. ansible/config/manager.py +89 -11
  12. ansible/constants.py +32 -9
  13. ansible/errors/__init__.py +5 -0
  14. ansible/executor/interpreter_discovery.py +1 -1
  15. ansible/executor/play_iterator.py +16 -0
  16. ansible/executor/playbook_executor.py +1 -4
  17. ansible/executor/powershell/become_wrapper.ps1 +4 -5
  18. ansible/executor/powershell/bootstrap_wrapper.ps1 +2 -3
  19. ansible/executor/powershell/exec_wrapper.ps1 +1 -1
  20. ansible/executor/powershell/module_manifest.py +2 -2
  21. ansible/executor/task_executor.py +50 -39
  22. ansible/executor/task_queue_manager.py +1 -1
  23. ansible/executor/task_result.py +1 -1
  24. ansible/galaxy/api.py +3 -4
  25. ansible/galaxy/collection/__init__.py +21 -10
  26. ansible/galaxy/collection/concrete_artifact_manager.py +2 -2
  27. ansible/galaxy/collection/galaxy_api_proxy.py +10 -16
  28. ansible/galaxy/collection/gpg.py +17 -23
  29. ansible/galaxy/data/COPYING +7 -0
  30. ansible/galaxy/data/apb/Dockerfile.j2 +1 -0
  31. ansible/galaxy/data/apb/Makefile.j2 +1 -0
  32. ansible/galaxy/data/apb/README.md +7 -3
  33. ansible/galaxy/data/apb/apb.yml.j2 +1 -0
  34. ansible/galaxy/data/apb/defaults/main.yml.j2 +1 -0
  35. ansible/galaxy/data/apb/handlers/main.yml.j2 +1 -0
  36. ansible/galaxy/data/apb/meta/main.yml.j2 +1 -0
  37. ansible/galaxy/data/apb/playbooks/deprovision.yml.j2 +1 -0
  38. ansible/galaxy/data/apb/playbooks/provision.yml.j2 +1 -0
  39. ansible/galaxy/data/apb/tasks/main.yml.j2 +1 -0
  40. ansible/galaxy/data/apb/tests/ansible.cfg +1 -0
  41. ansible/galaxy/data/apb/tests/inventory +1 -0
  42. ansible/galaxy/data/apb/tests/test.yml.j2 +1 -0
  43. ansible/galaxy/data/apb/vars/main.yml.j2 +1 -0
  44. ansible/galaxy/data/collections_galaxy_meta.yml +1 -0
  45. ansible/galaxy/data/container/defaults/main.yml.j2 +1 -0
  46. ansible/galaxy/data/container/handlers/main.yml.j2 +1 -0
  47. ansible/galaxy/data/container/meta/container.yml.j2 +1 -0
  48. ansible/galaxy/data/container/meta/main.yml.j2 +1 -0
  49. ansible/galaxy/data/container/tasks/main.yml.j2 +1 -0
  50. ansible/galaxy/data/container/tests/ansible.cfg +1 -0
  51. ansible/galaxy/data/container/tests/inventory +1 -0
  52. ansible/galaxy/data/container/tests/test.yml.j2 +1 -0
  53. ansible/galaxy/data/container/vars/main.yml.j2 +1 -0
  54. ansible/galaxy/data/default/collection/README.md.j2 +1 -0
  55. ansible/galaxy/data/default/collection/galaxy.yml.j2 +1 -0
  56. ansible/galaxy/data/default/collection/meta/runtime.yml +1 -0
  57. ansible/galaxy/data/default/collection/plugins/README.md.j2 +1 -0
  58. ansible/galaxy/data/default/role/defaults/main.yml.j2 +1 -0
  59. ansible/galaxy/data/default/role/handlers/main.yml.j2 +1 -0
  60. ansible/galaxy/data/default/role/meta/main.yml.j2 +1 -0
  61. ansible/galaxy/data/default/role/tasks/main.yml.j2 +1 -0
  62. ansible/galaxy/data/default/role/tests/inventory +1 -0
  63. ansible/galaxy/data/default/role/tests/test.yml.j2 +1 -0
  64. ansible/galaxy/data/default/role/vars/main.yml.j2 +1 -0
  65. ansible/galaxy/data/network/cliconf_plugins/example.py.j2 +1 -0
  66. ansible/galaxy/data/network/defaults/main.yml.j2 +1 -0
  67. ansible/galaxy/data/network/library/example_command.py.j2 +1 -0
  68. ansible/galaxy/data/network/library/example_config.py.j2 +1 -0
  69. ansible/galaxy/data/network/library/example_facts.py.j2 +1 -0
  70. ansible/galaxy/data/network/meta/main.yml.j2 +1 -0
  71. ansible/galaxy/data/network/module_utils/example.py.j2 +1 -0
  72. ansible/galaxy/data/network/netconf_plugins/example.py.j2 +1 -0
  73. ansible/galaxy/data/network/tasks/main.yml.j2 +1 -0
  74. ansible/galaxy/data/network/terminal_plugins/example.py.j2 +1 -0
  75. ansible/galaxy/data/network/tests/inventory +1 -0
  76. ansible/galaxy/data/network/tests/test.yml.j2 +1 -0
  77. ansible/galaxy/data/network/vars/main.yml.j2 +1 -0
  78. ansible/galaxy/dependency_resolution/providers.py +3 -3
  79. ansible/galaxy/role.py +1 -1
  80. ansible/galaxy/token.py +20 -8
  81. ansible/keyword_desc.yml +1 -1
  82. ansible/module_utils/_internal/__init__.py +0 -0
  83. ansible/module_utils/_internal/_concurrent/__init__.py +0 -0
  84. ansible/module_utils/_internal/_concurrent/_daemon_threading.py +28 -0
  85. ansible/module_utils/_internal/_concurrent/_futures.py +21 -0
  86. ansible/module_utils/ansible_release.py +2 -2
  87. ansible/module_utils/api.py +2 -2
  88. ansible/module_utils/basic.py +8 -8
  89. ansible/module_utils/common/collections.py +1 -1
  90. ansible/module_utils/common/file.py +0 -6
  91. ansible/module_utils/common/process.py +22 -9
  92. ansible/module_utils/common/text/converters.py +5 -8
  93. ansible/module_utils/common/text/formatters.py +20 -4
  94. ansible/module_utils/common/validation.py +33 -25
  95. ansible/module_utils/compat/paramiko.py +6 -1
  96. ansible/module_utils/compat/selinux.py +2 -2
  97. ansible/module_utils/connection.py +8 -24
  98. ansible/module_utils/csharp/Ansible.Become.cs +14 -25
  99. ansible/module_utils/csharp/Ansible.Process.cs +1 -1
  100. ansible/module_utils/distro/__init__.py +1 -1
  101. ansible/module_utils/distro/_distro.py +8 -4
  102. ansible/module_utils/facts/collector.py +2 -0
  103. ansible/module_utils/facts/default_collectors.py +3 -1
  104. ansible/module_utils/facts/hardware/aix.py +54 -52
  105. ansible/module_utils/facts/hardware/darwin.py +37 -34
  106. ansible/module_utils/facts/hardware/freebsd.py +55 -15
  107. ansible/module_utils/facts/hardware/hpux.py +3 -0
  108. ansible/module_utils/facts/hardware/linux.py +101 -57
  109. ansible/module_utils/facts/hardware/netbsd.py +3 -0
  110. ansible/module_utils/facts/hardware/openbsd.py +4 -1
  111. ansible/module_utils/facts/hardware/sunos.py +7 -1
  112. ansible/module_utils/facts/network/aix.py +16 -17
  113. ansible/module_utils/facts/network/fc_wwn.py +4 -1
  114. ansible/module_utils/facts/network/hpux.py +21 -4
  115. ansible/module_utils/facts/network/iscsi.py +7 -8
  116. ansible/module_utils/facts/network/linux.py +0 -2
  117. ansible/module_utils/facts/other/facter.py +9 -4
  118. ansible/module_utils/facts/other/ohai.py +5 -5
  119. ansible/module_utils/facts/packages.py +49 -7
  120. ansible/module_utils/facts/sysctl.py +33 -31
  121. ansible/module_utils/facts/system/distribution.py +1 -1
  122. ansible/module_utils/facts/system/local.py +12 -22
  123. ansible/module_utils/facts/system/service_mgr.py +3 -1
  124. ansible/module_utils/facts/system/systemd.py +47 -0
  125. ansible/module_utils/powershell/Ansible.ModuleUtils.AddType.psm1 +1 -1
  126. ansible/module_utils/powershell/Ansible.ModuleUtils.CamelConversion.psm1 +1 -1
  127. ansible/module_utils/splitter.py +1 -1
  128. ansible/modules/add_host.py +1 -1
  129. ansible/modules/apt.py +43 -32
  130. ansible/modules/apt_key.py +6 -6
  131. ansible/modules/apt_repository.py +23 -14
  132. ansible/modules/assemble.py +7 -2
  133. ansible/modules/assert.py +4 -4
  134. ansible/modules/blockinfile.py +3 -6
  135. ansible/modules/command.py +1 -1
  136. ansible/modules/copy.py +4 -4
  137. ansible/modules/cron.py +13 -10
  138. ansible/modules/deb822_repository.py +16 -17
  139. ansible/modules/debconf.py +9 -9
  140. ansible/modules/debug.py +1 -1
  141. ansible/modules/dnf.py +79 -164
  142. ansible/modules/dnf5.py +54 -29
  143. ansible/modules/dpkg_selections.py +2 -2
  144. ansible/modules/expect.py +2 -2
  145. ansible/modules/fetch.py +2 -2
  146. ansible/modules/file.py +5 -3
  147. ansible/modules/find.py +40 -12
  148. ansible/modules/gather_facts.py +4 -2
  149. ansible/modules/get_url.py +29 -24
  150. ansible/modules/git.py +35 -35
  151. ansible/modules/group.py +71 -1
  152. ansible/modules/hostname.py +2 -4
  153. ansible/modules/include_vars.py +5 -5
  154. ansible/modules/iptables.py +13 -16
  155. ansible/modules/known_hosts.py +16 -13
  156. ansible/modules/lineinfile.py +1 -4
  157. ansible/modules/meta.py +6 -1
  158. ansible/modules/mount_facts.py +651 -0
  159. ansible/modules/package_facts.py +63 -80
  160. ansible/modules/pause.py +4 -3
  161. ansible/modules/pip.py +14 -14
  162. ansible/modules/replace.py +1 -4
  163. ansible/modules/rpm_key.py +31 -11
  164. ansible/modules/service.py +8 -8
  165. ansible/modules/service_facts.py +20 -5
  166. ansible/modules/set_stats.py +1 -1
  167. ansible/modules/setup.py +3 -3
  168. ansible/modules/stat.py +3 -3
  169. ansible/modules/subversion.py +1 -1
  170. ansible/modules/systemd.py +16 -10
  171. ansible/modules/systemd_service.py +16 -10
  172. ansible/modules/sysvinit.py +4 -4
  173. ansible/modules/unarchive.py +35 -22
  174. ansible/modules/uri.py +24 -18
  175. ansible/modules/user.py +145 -12
  176. ansible/modules/validate_argument_spec.py +3 -3
  177. ansible/modules/wait_for_connection.py +2 -1
  178. ansible/modules/yum_repository.py +136 -179
  179. ansible/parsing/dataloader.py +2 -2
  180. ansible/parsing/mod_args.py +11 -10
  181. ansible/parsing/vault/__init__.py +8 -3
  182. ansible/parsing/yaml/constructor.py +10 -8
  183. ansible/parsing/yaml/objects.py +1 -1
  184. ansible/playbook/base.py +12 -23
  185. ansible/playbook/helpers.py +4 -0
  186. ansible/playbook/loop_control.py +8 -0
  187. ansible/playbook/play.py +4 -22
  188. ansible/playbook/play_context.py +0 -16
  189. ansible/playbook/playbook_include.py +2 -2
  190. ansible/playbook/role/__init__.py +2 -2
  191. ansible/plugins/__init__.py +2 -0
  192. ansible/plugins/action/__init__.py +7 -9
  193. ansible/plugins/action/dnf.py +7 -5
  194. ansible/plugins/action/package.py +5 -4
  195. ansible/plugins/action/reboot.py +2 -2
  196. ansible/plugins/become/__init__.py +1 -1
  197. ansible/plugins/callback/__init__.py +44 -3
  198. ansible/plugins/callback/default.py +1 -1
  199. ansible/plugins/cliconf/__init__.py +1 -1
  200. ansible/plugins/connection/paramiko_ssh.py +2 -80
  201. ansible/plugins/connection/psrp.py +33 -82
  202. ansible/plugins/connection/ssh.py +0 -8
  203. ansible/plugins/connection/winrm.py +46 -1
  204. ansible/plugins/doc_fragments/connection_pipelining.py +2 -2
  205. ansible/plugins/doc_fragments/constructed.py +10 -10
  206. ansible/plugins/doc_fragments/default_callback.py +8 -8
  207. ansible/plugins/doc_fragments/files.py +5 -5
  208. ansible/plugins/doc_fragments/inventory_cache.py +2 -2
  209. ansible/plugins/doc_fragments/result_format_callback.py +6 -6
  210. ansible/plugins/doc_fragments/return_common.py +1 -1
  211. ansible/plugins/doc_fragments/shell_common.py +2 -10
  212. ansible/plugins/doc_fragments/shell_windows.py +0 -9
  213. ansible/plugins/doc_fragments/url.py +2 -2
  214. ansible/plugins/doc_fragments/url_windows.py +4 -5
  215. ansible/plugins/doc_fragments/validate.py +1 -1
  216. ansible/plugins/filter/core.py +2 -0
  217. ansible/plugins/filter/human_to_bytes.yml +9 -0
  218. ansible/plugins/filter/password_hash.yml +1 -1
  219. ansible/plugins/filter/strftime.yml +1 -1
  220. ansible/plugins/filter/to_nice_json.yml +7 -3
  221. ansible/plugins/filter/to_uuid.yml +1 -1
  222. ansible/plugins/inventory/script.py +1 -1
  223. ansible/plugins/list.py +1 -1
  224. ansible/plugins/loader.py +0 -11
  225. ansible/plugins/lookup/config.py +1 -1
  226. ansible/plugins/lookup/csvfile.py +21 -9
  227. ansible/plugins/lookup/env.py +8 -9
  228. ansible/plugins/lookup/ini.py +10 -1
  229. ansible/plugins/lookup/random_choice.py +2 -2
  230. ansible/plugins/lookup/url.py +7 -2
  231. ansible/plugins/shell/__init__.py +15 -20
  232. ansible/plugins/shell/powershell.py +9 -6
  233. ansible/plugins/strategy/__init__.py +16 -7
  234. ansible/plugins/test/core.py +23 -1
  235. ansible/plugins/test/issubset.yml +1 -1
  236. ansible/plugins/test/subset.yml +1 -1
  237. ansible/plugins/test/timedout.yml +20 -0
  238. ansible/plugins/test/vault_encrypted.yml +6 -6
  239. ansible/plugins/test/vaulted_file.yml +19 -0
  240. ansible/release.py +2 -2
  241. ansible/template/__init__.py +3 -8
  242. ansible/utils/collection_loader/_collection_finder.py +23 -55
  243. ansible/utils/display.py +44 -31
  244. ansible/utils/jsonrpc.py +1 -1
  245. ansible/utils/listify.py +1 -5
  246. ansible/utils/path.py +3 -0
  247. ansible/utils/vars.py +18 -27
  248. ansible/vars/manager.py +7 -150
  249. ansible/vars/plugins.py +1 -1
  250. ansible_core-2.18.0.dist-info/Apache-License.txt +202 -0
  251. {ansible_core-2.17.6.dist-info → ansible_core-2.18.0.dist-info}/METADATA +36 -23
  252. ansible_core-2.18.0.dist-info/MIT-license.txt +14 -0
  253. ansible_core-2.18.0.dist-info/PSF-license.txt +48 -0
  254. {ansible_core-2.17.6.dist-info → ansible_core-2.18.0.dist-info}/RECORD +316 -311
  255. {ansible_core-2.17.6.dist-info → ansible_core-2.18.0.dist-info}/entry_points.txt +1 -1
  256. ansible_core-2.18.0.dist-info/simplified_bsd.txt +8 -0
  257. ansible_test/_data/completion/docker.txt +7 -7
  258. ansible_test/_data/completion/remote.txt +5 -4
  259. ansible_test/_data/completion/windows.txt +4 -4
  260. ansible_test/_data/requirements/ansible-test.txt +1 -2
  261. ansible_test/_data/requirements/constraints.txt +1 -2
  262. ansible_test/_data/requirements/sanity.ansible-doc.txt +3 -3
  263. ansible_test/_data/requirements/sanity.changelog.in +1 -1
  264. ansible_test/_data/requirements/sanity.changelog.txt +4 -4
  265. ansible_test/_data/requirements/sanity.import.plugin.txt +2 -2
  266. ansible_test/_data/requirements/sanity.import.txt +1 -1
  267. ansible_test/_data/requirements/sanity.integration-aliases.txt +1 -1
  268. ansible_test/_data/requirements/sanity.pep8.txt +1 -1
  269. ansible_test/_data/requirements/sanity.pylint.txt +6 -8
  270. ansible_test/_data/requirements/sanity.runtime-metadata.txt +2 -2
  271. ansible_test/_data/requirements/sanity.validate-modules.txt +3 -3
  272. ansible_test/_data/requirements/sanity.yamllint.in +1 -0
  273. ansible_test/_data/requirements/sanity.yamllint.txt +1 -1
  274. ansible_test/_internal/ansible_util.py +8 -35
  275. ansible_test/_internal/ci/azp.py +1 -1
  276. ansible_test/_internal/classification/__init__.py +0 -2
  277. ansible_test/_internal/cli/parsers/key_value_parsers.py +3 -0
  278. ansible_test/_internal/commands/integration/cloud/hcloud.py +1 -1
  279. ansible_test/_internal/commands/integration/cloud/httptester.py +1 -1
  280. ansible_test/_internal/commands/integration/cloud/nios.py +1 -1
  281. ansible_test/_internal/commands/sanity/__init__.py +96 -19
  282. ansible_test/_internal/commands/sanity/pylint.py +20 -24
  283. ansible_test/_internal/completion.py +2 -0
  284. ansible_test/_internal/constants.py +0 -1
  285. ansible_test/_internal/coverage_util.py +1 -2
  286. ansible_test/_internal/docker_util.py +1 -1
  287. ansible_test/_internal/encoding.py +4 -4
  288. ansible_test/_internal/host_configs.py +10 -0
  289. ansible_test/_internal/host_profiles.py +9 -13
  290. ansible_test/_internal/pypi_proxy.py +1 -1
  291. ansible_test/_internal/python_requirements.py +5 -14
  292. ansible_test/_internal/timeout.py +1 -1
  293. ansible_test/_internal/util.py +40 -0
  294. ansible_test/_internal/util_common.py +5 -1
  295. ansible_test/_util/controller/sanity/code-smell/action-plugin-docs.json +3 -1
  296. ansible_test/_util/controller/sanity/code-smell/action-plugin-docs.py +6 -3
  297. ansible_test/_util/controller/sanity/code-smell/empty-init.json +0 -2
  298. ansible_test/_util/controller/sanity/pylint/config/ansible-test-target.cfg +5 -0
  299. ansible_test/_util/controller/sanity/pylint/config/ansible-test.cfg +5 -0
  300. ansible_test/_util/controller/sanity/pylint/config/code-smell.cfg +5 -0
  301. ansible_test/_util/controller/sanity/pylint/config/collection.cfg +6 -0
  302. ansible_test/_util/controller/sanity/pylint/config/default.cfg +6 -0
  303. ansible_test/_util/controller/sanity/pylint/plugins/deprecated.py +1 -19
  304. ansible_test/_util/controller/sanity/shellcheck/exclude.txt +1 -0
  305. ansible_test/_util/controller/sanity/validate-modules/validate_modules/main.py +67 -2
  306. ansible_test/_util/controller/sanity/validate-modules/validate_modules/schema.py +27 -5
  307. ansible_test/_util/target/cli/ansible_test_cli_stub.py +0 -0
  308. ansible_test/_util/target/common/constants.py +2 -2
  309. ansible_test/_util/target/injector/python.py +5 -0
  310. ansible_test/_util/target/pytest/plugins/ansible_pytest_coverage.py +6 -0
  311. ansible_test/_util/target/sanity/import/importer.py +1 -1
  312. ansible_test/_util/target/setup/bootstrap.sh +6 -17
  313. ansible_test/_util/target/setup/requirements.py +18 -24
  314. ansible_test/config/config.yml +1 -1
  315. ansible_core-2.17.6.data/scripts/ansible-test +0 -44
  316. ansible_test/_data/requirements/sanity.mypy.in +0 -10
  317. ansible_test/_data/requirements/sanity.mypy.txt +0 -18
  318. ansible_test/_internal/commands/sanity/mypy.py +0 -274
  319. ansible_test/_util/controller/sanity/mypy/ansible-core.ini +0 -116
  320. ansible_test/_util/controller/sanity/mypy/ansible-test.ini +0 -27
  321. ansible_test/_util/controller/sanity/mypy/modules.ini +0 -92
  322. ansible_test/_util/controller/sanity/mypy/packaging.ini +0 -20
  323. {ansible_core-2.17.6.dist-info → ansible_core-2.18.0.dist-info}/COPYING +0 -0
  324. {ansible_core-2.17.6.dist-info → ansible_core-2.18.0.dist-info}/WHEEL +0 -0
  325. {ansible_core-2.17.6.dist-info → ansible_core-2.18.0.dist-info}/top_level.txt +0 -0
@@ -1,274 +0,0 @@
1
- """Sanity test which executes mypy."""
2
- from __future__ import annotations
3
-
4
- import dataclasses
5
- import os
6
- import re
7
- import typing as t
8
-
9
- from . import (
10
- SanityMultipleVersion,
11
- SanityMessage,
12
- SanityFailure,
13
- SanitySuccess,
14
- SanitySkipped,
15
- SanityTargets,
16
- create_sanity_virtualenv,
17
- )
18
-
19
- from ...constants import (
20
- CONTROLLER_PYTHON_VERSIONS,
21
- REMOTE_ONLY_PYTHON_VERSIONS,
22
- SUPPORTED_PYTHON_VERSIONS,
23
- )
24
-
25
- from ...test import (
26
- TestResult,
27
- )
28
-
29
- from ...target import (
30
- TestTarget,
31
- )
32
-
33
- from ...util import (
34
- SubprocessError,
35
- display,
36
- parse_to_list_of_dict,
37
- ANSIBLE_TEST_CONTROLLER_ROOT,
38
- ApplicationError,
39
- is_subdir,
40
- str_to_version,
41
- )
42
-
43
- from ...util_common import (
44
- intercept_python,
45
- )
46
-
47
- from ...ansible_util import (
48
- ansible_environment,
49
- )
50
-
51
- from ...config import (
52
- SanityConfig,
53
- )
54
-
55
- from ...host_configs import (
56
- PythonConfig,
57
- VirtualPythonConfig,
58
- )
59
-
60
-
61
- class MypyTest(SanityMultipleVersion):
62
- """Sanity test which executes mypy."""
63
-
64
- ansible_only = True
65
-
66
- vendored_paths = (
67
- 'lib/ansible/module_utils/six/__init__.py',
68
- 'lib/ansible/module_utils/distro/_distro.py',
69
- )
70
-
71
- def filter_targets(self, targets: list[TestTarget]) -> list[TestTarget]:
72
- """Return the given list of test targets, filtered to include only those relevant for the test."""
73
- return [target for target in targets if os.path.splitext(target.path)[1] == '.py' and target.path not in self.vendored_paths and (
74
- target.path.startswith('lib/ansible/') or target.path.startswith('test/lib/ansible_test/_internal/')
75
- or target.path.startswith('packaging/')
76
- or target.path.startswith('test/lib/ansible_test/_util/target/sanity/import/'))]
77
-
78
- @property
79
- def error_code(self) -> t.Optional[str]:
80
- """Error code for ansible-test matching the format used by the underlying test program, or None if the program does not use error codes."""
81
- return 'ansible-test'
82
-
83
- @property
84
- def needs_pypi(self) -> bool:
85
- """True if the test requires PyPI, otherwise False."""
86
- return True
87
-
88
- @property
89
- def supported_python_versions(self) -> t.Optional[tuple[str, ...]]:
90
- """A tuple of supported Python versions or None if the test does not depend on specific Python versions."""
91
- # Because the version of typeshed mypy use in 1.9 doesn't support 3.7, neither does mypy 1.9.
92
- # see: https://mypy-lang.blogspot.com/2024/03/mypy-19-released.html
93
- return tuple(version for version in SUPPORTED_PYTHON_VERSIONS if str_to_version(version) >= (3, 8))
94
-
95
- def test(self, args: SanityConfig, targets: SanityTargets, python: PythonConfig) -> TestResult:
96
- settings = self.load_processor(args, python.version)
97
-
98
- paths = [target.path for target in targets.include]
99
-
100
- virtualenv_python = create_sanity_virtualenv(args, args.controller_python, self.name)
101
-
102
- if args.prime_venvs:
103
- return SanitySkipped(self.name, python_version=python.version)
104
-
105
- if not virtualenv_python:
106
- display.warning(f'Skipping sanity test "{self.name}" due to missing virtual environment support on Python {args.controller_python.version}.')
107
- return SanitySkipped(self.name, python.version)
108
-
109
- controller_python_versions = CONTROLLER_PYTHON_VERSIONS
110
- remote_only_python_versions = REMOTE_ONLY_PYTHON_VERSIONS
111
-
112
- contexts = (
113
- MyPyContext('ansible-test', ['test/lib/ansible_test/_util/target/sanity/import/'], controller_python_versions),
114
- MyPyContext('ansible-test', ['test/lib/ansible_test/_internal/'], controller_python_versions),
115
- MyPyContext('ansible-core', ['lib/ansible/'], controller_python_versions),
116
- MyPyContext('modules', ['lib/ansible/modules/', 'lib/ansible/module_utils/'], remote_only_python_versions),
117
- MyPyContext('packaging', ['packaging/'], controller_python_versions),
118
- )
119
-
120
- unfiltered_messages: list[SanityMessage] = []
121
-
122
- for context in contexts:
123
- if python.version not in context.python_versions:
124
- continue
125
-
126
- unfiltered_messages.extend(self.test_context(args, virtualenv_python, python, context, paths))
127
-
128
- notices = []
129
- messages = []
130
-
131
- for message in unfiltered_messages:
132
- if message.level != 'error':
133
- notices.append(message)
134
- continue
135
-
136
- match = re.search(r'^(?P<message>.*) {2}\[(?P<code>.*)]$', message.message)
137
-
138
- messages.append(SanityMessage(
139
- message=match.group('message'),
140
- path=message.path,
141
- line=message.line,
142
- column=message.column,
143
- level=message.level,
144
- code=match.group('code'),
145
- ))
146
-
147
- for notice in notices:
148
- display.info(notice.format(), verbosity=3)
149
-
150
- # The following error codes from mypy indicate that results are incomplete.
151
- # That prevents the test from completing successfully, just as if mypy were to traceback or generate unexpected output.
152
- fatal_error_codes = {
153
- 'import',
154
- 'syntax',
155
- }
156
-
157
- fatal_errors = [message for message in messages if message.code in fatal_error_codes]
158
-
159
- if fatal_errors:
160
- error_message = '\n'.join(error.format() for error in fatal_errors)
161
- raise ApplicationError(f'Encountered {len(fatal_errors)} fatal errors reported by mypy:\n{error_message}')
162
-
163
- paths_set = set(paths)
164
-
165
- # Only report messages for paths that were specified as targets.
166
- # Imports in our code are followed by mypy in order to perform its analysis, which is important for accurate results.
167
- # However, it will also report issues on those files, which is not the desired behavior.
168
- messages = [message for message in messages if message.path in paths_set]
169
-
170
- if args.explain:
171
- return SanitySuccess(self.name, python_version=python.version)
172
-
173
- results = settings.process_errors(messages, paths)
174
-
175
- if results:
176
- return SanityFailure(self.name, messages=results, python_version=python.version)
177
-
178
- return SanitySuccess(self.name, python_version=python.version)
179
-
180
- @staticmethod
181
- def test_context(
182
- args: SanityConfig,
183
- virtualenv_python: VirtualPythonConfig,
184
- python: PythonConfig,
185
- context: MyPyContext,
186
- paths: list[str],
187
- ) -> list[SanityMessage]:
188
- """Run mypy tests for the specified context."""
189
- context_paths = [path for path in paths if any(is_subdir(path, match_path) for match_path in context.paths)]
190
-
191
- if not context_paths:
192
- return []
193
-
194
- config_path = os.path.join(ANSIBLE_TEST_CONTROLLER_ROOT, 'sanity', 'mypy', f'{context.name}.ini')
195
-
196
- display.info(f'Checking context "{context.name}"', verbosity=1)
197
-
198
- env = ansible_environment(args, color=False)
199
- env['MYPYPATH'] = env['PYTHONPATH']
200
-
201
- # The --no-site-packages option should not be used, as it will prevent loading of type stubs from the sanity test virtual environment.
202
-
203
- # Enabling the --warn-unused-configs option would help keep the config files clean.
204
- # However, the option can only be used when all files in tested contexts are evaluated.
205
- # Unfortunately sanity tests have no way of making that determination currently.
206
- # The option is also incompatible with incremental mode and caching.
207
-
208
- cmd = [
209
- # Below are arguments common to all contexts.
210
- # They are kept here to avoid repetition in each config file.
211
- virtualenv_python.path,
212
- '-m', 'mypy',
213
- '--show-column-numbers',
214
- '--show-error-codes',
215
- '--no-error-summary',
216
- # This is a fairly common pattern in our code, so we'll allow it.
217
- '--allow-redefinition',
218
- # Since we specify the path(s) to test, it's important that mypy is configured to use the default behavior of following imports.
219
- '--follow-imports', 'normal',
220
- # Incremental results and caching do not provide significant performance benefits.
221
- # It also prevents the use of the --warn-unused-configs option.
222
- '--no-incremental',
223
- '--cache-dir', '/dev/null',
224
- # The platform is specified here so that results are consistent regardless of what platform the tests are run from.
225
- # In the future, if testing of other platforms is desired, the platform should become part of the test specification, just like the Python version.
226
- '--platform', 'linux',
227
- # Despite what the documentation [1] states, the --python-version option does not cause mypy to search for a corresponding Python executable.
228
- # It will instead use the Python executable that is used to run mypy itself.
229
- # The --python-executable option can be used to specify the Python executable, with the default being the executable used to run mypy.
230
- # As a precaution, that option is used in case the behavior of mypy is updated in the future to match the documentation.
231
- # That should help guarantee that the Python executable providing type hints is the one used to run mypy.
232
- # [1] https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-python-version
233
- '--python-executable', virtualenv_python.path,
234
- '--python-version', python.version,
235
- # Below are context specific arguments.
236
- # They are primarily useful for listing individual 'ignore_missing_imports' entries instead of using a global ignore.
237
- '--config-file', config_path,
238
- ] # fmt: skip
239
-
240
- cmd.extend(context_paths)
241
-
242
- try:
243
- stdout, stderr = intercept_python(args, virtualenv_python, cmd, env, capture=True)
244
-
245
- if stdout or stderr:
246
- raise SubprocessError(cmd, stdout=stdout, stderr=stderr)
247
- except SubprocessError as ex:
248
- if ex.status != 1 or ex.stderr or not ex.stdout:
249
- raise
250
-
251
- stdout = ex.stdout
252
-
253
- pattern = r'^(?P<path>[^:]*):(?P<line>[0-9]+):((?P<column>[0-9]+):)? (?P<level>[^:]+): (?P<message>.*)$'
254
-
255
- parsed = parse_to_list_of_dict(pattern, stdout or '')
256
-
257
- messages = [SanityMessage(
258
- level=r['level'],
259
- message=r['message'],
260
- path=r['path'],
261
- line=int(r['line']),
262
- column=int(r.get('column') or '0'),
263
- ) for r in parsed]
264
-
265
- return messages
266
-
267
-
268
- @dataclasses.dataclass(frozen=True)
269
- class MyPyContext:
270
- """Context details for a single run of mypy."""
271
-
272
- name: str
273
- paths: list[str]
274
- python_versions: tuple[str, ...]
@@ -1,116 +0,0 @@
1
- # IMPORTANT
2
- # Set "ignore_missing_imports" per package below, rather than globally.
3
- # That will help identify missing type stubs that should be added to the sanity test environment.
4
-
5
- [mypy]
6
- # There are ~20 errors reported in ansible-core when strict optional checking is enabled.
7
- # Until the number of occurrences are reduced, it's better to disable strict checking.
8
- strict_optional = False
9
- # There are ~70 errors reported in ansible-core when checking attributes.
10
- # Until the number of occurrences are reduced, it's better to disable the check.
11
- disable_error_code = attr-defined
12
-
13
- [mypy-ansible.module_utils.six.moves.*]
14
- ignore_missing_imports = True
15
-
16
- [mypy-passlib.*]
17
- ignore_missing_imports = True
18
-
19
- [mypy-pexpect.*]
20
- ignore_missing_imports = True
21
-
22
- [mypy-pypsrp.*]
23
- ignore_missing_imports = True
24
-
25
- [mypy-winrm.*]
26
- ignore_missing_imports = True
27
-
28
- [mypy-kerberos.*]
29
- ignore_missing_imports = True
30
-
31
- [mypy-xmltodict.*]
32
- ignore_missing_imports = True
33
-
34
- [mypy-md5.*]
35
- ignore_missing_imports = True
36
-
37
- [mypy-imp.*]
38
- ignore_missing_imports = True
39
-
40
- [mypy-scp.*]
41
- ignore_missing_imports = True
42
-
43
- [mypy-ncclient.*]
44
- ignore_missing_imports = True
45
-
46
- [mypy-lxml.*]
47
- ignore_missing_imports = True
48
-
49
- [mypy-rpmUtils.*]
50
- ignore_missing_imports = True
51
-
52
- [mypy-rpm.*]
53
- ignore_missing_imports = True
54
-
55
- [mypy-psutil.*]
56
- ignore_missing_imports = True
57
-
58
- [mypy-dnf.*]
59
- ignore_missing_imports = True
60
-
61
- [mypy-apt.*]
62
- ignore_missing_imports = True
63
-
64
- [mypy-apt_pkg.*]
65
- ignore_missing_imports = True
66
-
67
- [mypy-gssapi.*]
68
- ignore_missing_imports = True
69
-
70
- [mypy-_ssl.*]
71
- ignore_missing_imports = True
72
-
73
- [mypy-urllib_gssapi.*]
74
- ignore_missing_imports = True
75
-
76
- [mypy-systemd.*]
77
- ignore_missing_imports = True
78
-
79
- [mypy-sha.*]
80
- ignore_missing_imports = True
81
-
82
- [mypy-distro.*]
83
- ignore_missing_imports = True
84
-
85
- [mypy-resolvelib.*]
86
- ignore_missing_imports = True
87
-
88
- [mypy-urlparse.*]
89
- ignore_missing_imports = True
90
-
91
- [mypy-argcomplete.*]
92
- ignore_missing_imports = True
93
-
94
- [mypy-selinux.*]
95
- ignore_missing_imports = True
96
-
97
- [mypy-urllib2.*]
98
- ignore_missing_imports = True
99
-
100
- [mypy-httplib.*]
101
- ignore_missing_imports = True
102
-
103
- [mypy-compiler.*]
104
- ignore_missing_imports = True
105
-
106
- [mypy-aptsources.*]
107
- ignore_missing_imports = True
108
-
109
- [mypy-urllib3.*]
110
- ignore_missing_imports = True
111
-
112
- [mypy-requests.*]
113
- ignore_missing_imports = True
114
-
115
- [mypy-jinja2.nativetypes]
116
- ignore_missing_imports = True
@@ -1,27 +0,0 @@
1
- # IMPORTANT
2
- # Set "ignore_missing_imports" per package below, rather than globally.
3
- # That will help identify missing type stubs that should be added to the sanity test environment.
4
-
5
- [mypy]
6
- # There are ~350 errors reported in ansible-test when strict optional checking is enabled.
7
- # Until the number of occurrences are greatly reduced, it's better to disable strict checking.
8
- strict_optional = False
9
- # There are ~13 type-abstract errors reported in ansible-test.
10
- # This is due to assumptions mypy makes about Type and abstract types.
11
- # See: https://discuss.python.org/t/add-abstracttype-to-the-typing-module/21996/13
12
- disable_error_code = type-abstract
13
-
14
- [mypy-argcomplete]
15
- ignore_missing_imports = True
16
-
17
- [mypy-argcomplete.finders]
18
- ignore_missing_imports = True
19
-
20
- [mypy-coverage]
21
- ignore_missing_imports = True
22
-
23
- [mypy-ansible_release]
24
- ignore_missing_imports = True
25
-
26
- [mypy-StringIO]
27
- ignore_missing_imports = True
@@ -1,92 +0,0 @@
1
- # IMPORTANT
2
- # Set "ignore_missing_imports" per package below, rather than globally.
3
- # That will help identify missing type stubs that should be added to the sanity test environment.
4
-
5
- [mypy]
6
-
7
- [mypy-ansible.module_utils.six.moves.*]
8
- ignore_missing_imports = True
9
-
10
- [mypy-pexpect.*]
11
- ignore_missing_imports = True
12
-
13
- [mypy-md5.*]
14
- ignore_missing_imports = True
15
-
16
- [mypy-rpmUtils.*]
17
- ignore_missing_imports = True
18
-
19
- [mypy-rpm.*]
20
- ignore_missing_imports = True
21
-
22
- [mypy-psutil.*]
23
- ignore_missing_imports = True
24
-
25
- [mypy-dnf.*]
26
- ignore_missing_imports = True
27
-
28
- [mypy-apt.*]
29
- ignore_missing_imports = True
30
-
31
- [mypy-apt_pkg.*]
32
- ignore_missing_imports = True
33
-
34
- [mypy-gssapi.*]
35
- ignore_missing_imports = True
36
-
37
- [mypy-_ssl.*]
38
- ignore_missing_imports = True
39
-
40
- [mypy-urllib_gssapi.*]
41
- ignore_missing_imports = True
42
-
43
- [mypy-systemd.*]
44
- ignore_missing_imports = True
45
-
46
- [mypy-sha.*]
47
- ignore_missing_imports = True
48
-
49
- [mypy-distro.*]
50
- ignore_missing_imports = True
51
-
52
- [mypy-selinux.*]
53
- ignore_missing_imports = True
54
-
55
- [mypy-urllib2.*]
56
- ignore_missing_imports = True
57
-
58
- [mypy-httplib.*]
59
- ignore_missing_imports = True
60
-
61
- [mypy-compiler.*]
62
- ignore_missing_imports = True
63
-
64
- [mypy-aptsources.*]
65
- ignore_missing_imports = True
66
-
67
- [mypy-urllib3.*]
68
- ignore_missing_imports = True
69
-
70
- [mypy-requests.*]
71
- ignore_missing_imports = True
72
-
73
- [mypy-pkg_resources.*]
74
- ignore_missing_imports = True
75
-
76
- [mypy-urllib.*]
77
- ignore_missing_imports = True
78
-
79
- [mypy-email.*]
80
- ignore_missing_imports = True
81
-
82
- [mypy-selectors.*]
83
- ignore_missing_imports = True
84
-
85
- [mypy-importlib.*]
86
- ignore_missing_imports = True
87
-
88
- [mypy-collections.*]
89
- ignore_missing_imports = True
90
-
91
- [mypy-http.*]
92
- ignore_missing_imports = True
@@ -1,20 +0,0 @@
1
- # IMPORTANT
2
- # Set "ignore_missing_imports" per package below, rather than globally.
3
- # That will help identify missing type stubs that should be added to the sanity test environment.
4
-
5
- [mypy]
6
-
7
- [mypy-docutils]
8
- ignore_missing_imports = True
9
-
10
- [mypy-docutils.core]
11
- ignore_missing_imports = True
12
-
13
- [mypy-docutils.writers]
14
- ignore_missing_imports = True
15
-
16
- [mypy-docutils.writers.manpage]
17
- ignore_missing_imports = True
18
-
19
- [mypy-argcomplete]
20
- ignore_missing_imports = True