diff --git a/pyproject.toml b/pyproject.toml index 1ae48253fad..49811eb7477 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,8 +15,9 @@ skip = ["cloudinit/cmd/main.py", ".tox", "packages", "tools"] [tool.mypy] follow_imports = "silent" -warn_unused_ignores = "true" -warn_redundant_casts = "true" +check_untyped_defs = true +warn_redundant_casts = true +warn_unused_ignores = true exclude = [] [[tool.mypy.overrides]] @@ -39,6 +40,207 @@ module = [ ignore_missing_imports = true no_implicit_optional = true +[[tool.mypy.overrides]] +module = [ + "cloudinit.analyze", + "cloudinit.analyze.dump", + "cloudinit.analyze.show", + "cloudinit.cmd.devel.hotplug_hook", + "cloudinit.cmd.devel.make_mime", + "cloudinit.cmd.devel.net_convert", + "cloudinit.cmd.main", + "cloudinit.config.cc_apt_configure", + "cloudinit.config.cc_ca_certs", + "cloudinit.config.cc_growpart", + "cloudinit.config.cc_ntp", + "cloudinit.config.cc_power_state_change", + "cloudinit.config.cc_rsyslog", + "cloudinit.config.cc_ubuntu_pro", + "cloudinit.config.modules", + "cloudinit.config.schema", + "cloudinit.distros", + "cloudinit.distros.alpine", + "cloudinit.distros.azurelinux", + "cloudinit.distros.bsd", + "cloudinit.distros.opensuse", + "cloudinit.distros.parsers.hostname", + "cloudinit.distros.parsers.hosts", + "cloudinit.distros.parsers.resolv_conf", + "cloudinit.distros.ubuntu", + "cloudinit.distros.ug_util", + "cloudinit.helpers", + "cloudinit.log", + "cloudinit.mergers", + "cloudinit.net", + "cloudinit.net.cmdline", + "cloudinit.net.dhcp", + "cloudinit.net.eni", + "cloudinit.net.ephemeral", + "cloudinit.net.freebsd", + "cloudinit.net.netbsd", + "cloudinit.net.netplan", + "cloudinit.net.network_manager", + "cloudinit.net.network_state", + "cloudinit.net.networkd", + "cloudinit.net.sysconfig", + "cloudinit.netinfo", + "cloudinit.reporting.handlers", + "cloudinit.sources.DataSourceAzure", + "cloudinit.sources.DataSourceBigstep", + "cloudinit.sources.DataSourceCloudSigma", + "cloudinit.sources.DataSourceCloudStack", + "cloudinit.sources.DataSourceConfigDrive", + "cloudinit.sources.DataSourceDigitalOcean", + "cloudinit.sources.DataSourceEc2", + "cloudinit.sources.DataSourceExoscale", + "cloudinit.sources.DataSourceGCE", + "cloudinit.sources.DataSourceHetzner", + "cloudinit.sources.DataSourceIBMCloud", + "cloudinit.sources.DataSourceMAAS", + "cloudinit.sources.DataSourceNoCloud", + "cloudinit.sources.DataSourceOVF", + "cloudinit.sources.DataSourceOpenNebula", + "cloudinit.sources.DataSourceOpenStack", + "cloudinit.sources.DataSourceOracle", + "cloudinit.sources.DataSourceRbxCloud", + "cloudinit.sources.DataSourceScaleway", + "cloudinit.sources.DataSourceSmartOS", + "cloudinit.sources.DataSourceVMware", + "cloudinit.sources", + "cloudinit.sources.helpers.azure", + "cloudinit.sources.helpers.ec2", + "cloudinit.sources.helpers.netlink", + "cloudinit.sources.helpers.openstack", + "cloudinit.sources.helpers.vmware.imc.config_file", + "cloudinit.sources.helpers.vmware.imc.config_nic", + "cloudinit.sources.helpers.vultr", + "cloudinit.ssh_util", + "cloudinit.stages", + "cloudinit.temp_utils", + "cloudinit.templater", + "cloudinit.user_data", + "cloudinit.util", + "tests.integration_tests.instances", + "tests.unittests.analyze.test_show", + "tests.unittests.cmd.devel.test_hotplug_hook", + "tests.unittests.cmd.devel.test_render", + "tests.unittests.cmd.test_clean", + "tests.unittests.cmd.test_query", + "tests.unittests.cmd.test_status", + "tests.unittests.config.test_apt_configure_sources_list_v1", + "tests.unittests.config.test_apt_configure_sources_list_v3", + "tests.unittests.config.test_apt_source_v1", + "tests.unittests.config.test_apt_source_v3", + "tests.unittests.config.test_cc_ansible", + "tests.unittests.config.test_cc_apk_configure", + "tests.unittests.config.test_cc_apt_pipelining", + "tests.unittests.config.test_cc_bootcmd", + "tests.unittests.config.test_cc_ca_certs", + "tests.unittests.config.test_cc_chef", + "tests.unittests.config.test_cc_disable_ec2_metadata", + "tests.unittests.config.test_cc_final_message", + "tests.unittests.config.test_cc_growpart", + "tests.unittests.config.test_cc_grub_dpkg", + "tests.unittests.config.test_cc_install_hotplug", + "tests.unittests.config.test_cc_keys_to_console", + "tests.unittests.config.test_cc_landscape", + "tests.unittests.config.test_cc_locale", + "tests.unittests.config.test_cc_mcollective", + "tests.unittests.config.test_cc_mounts", + "tests.unittests.config.test_cc_ntp", + "tests.unittests.config.test_cc_phone_home", + "tests.unittests.config.test_cc_power_state_change", + "tests.unittests.config.test_cc_puppet", + "tests.unittests.config.test_cc_resizefs", + "tests.unittests.config.test_cc_resolv_conf", + "tests.unittests.config.test_cc_rh_subscription", + "tests.unittests.config.test_cc_rsyslog", + "tests.unittests.config.test_cc_runcmd", + "tests.unittests.config.test_cc_set_hostname", + "tests.unittests.config.test_cc_snap", + "tests.unittests.config.test_cc_ssh", + "tests.unittests.config.test_cc_timezone", + "tests.unittests.config.test_cc_ubuntu_autoinstall", + "tests.unittests.config.test_cc_ubuntu_drivers", + "tests.unittests.config.test_cc_ubuntu_pro", + "tests.unittests.config.test_cc_update_etc_hosts", + "tests.unittests.config.test_cc_users_groups", + "tests.unittests.config.test_cc_wireguard", + "tests.unittests.config.test_cc_yum_add_repo", + "tests.unittests.config.test_cc_zypper_add_repo", + "tests.unittests.config.test_modules", + "tests.unittests.config.test_schema", + "tests.unittests.conftest", + "tests.unittests.distros.test_alpine", + "tests.unittests.distros.test_hosts", + "tests.unittests.distros.test_ifconfig", + "tests.unittests.distros.test_netbsd", + "tests.unittests.distros.test_netconfig", + "tests.unittests.distros.test_opensuse", + "tests.unittests.distros.test_user_data_normalize", + "tests.unittests.helpers", + "tests.unittests.net.test_dhcp", + "tests.unittests.net.test_init", + "tests.unittests.net.test_network_state", + "tests.unittests.net.test_networkd", + "tests.unittests.runs.test_merge_run", + "tests.unittests.runs.test_simple_run", + "tests.unittests.sources.azure.test_errors", + "tests.unittests.sources.azure.test_imds", + "tests.unittests.sources.helpers.test_openstack", + "tests.unittests.sources.test_aliyun", + "tests.unittests.sources.test_altcloud", + "tests.unittests.sources.test_azure", + "tests.unittests.sources.test_azure_helper", + "tests.unittests.sources.test_cloudsigma", + "tests.unittests.sources.test_common", + "tests.unittests.sources.test_configdrive", + "tests.unittests.sources.test_digitalocean", + "tests.unittests.sources.test_ec2", + "tests.unittests.sources.test_exoscale", + "tests.unittests.sources.test_gce", + "tests.unittests.sources.test_init", + "tests.unittests.sources.test_lxd", + "tests.unittests.sources.test_maas", + "tests.unittests.sources.test_nocloud", + "tests.unittests.sources.test_opennebula", + "tests.unittests.sources.test_openstack", + "tests.unittests.sources.test_oracle", + "tests.unittests.sources.test_ovf", + "tests.unittests.sources.test_rbx", + "tests.unittests.sources.test_scaleway", + "tests.unittests.sources.test_smartos", + "tests.unittests.sources.test_upcloud", + "tests.unittests.sources.test_vultr", + "tests.unittests.sources.test_wsl", + "tests.unittests.sources.vmware.test_vmware_config_file", + "tests.unittests.test__init__", + "tests.unittests.test_apport", + "tests.unittests.test_builtin_handlers", + "tests.unittests.test_cli", + "tests.unittests.test_conftest", + "tests.unittests.test_data", + "tests.unittests.test_ds_identify", + "tests.unittests.test_helpers", + "tests.unittests.test_log", + "tests.unittests.test_merging", + "tests.unittests.test_net", + "tests.unittests.test_net_activators", + "tests.unittests.test_ssh_util", + "tests.unittests.test_stages", + "tests.unittests.test_subp", + "tests.unittests.test_templating", + "tests.unittests.test_upgrade", + "tests.unittests.test_url_helper", + "tests.unittests.test_util", + "tests.unittests.util", + + # tools/* + "netplan_schema_check", + "mock-meta", +] +check_untyped_defs = false + [tool.ruff] target-version = "py37" line-length = 79 diff --git a/tests/unittests/analyze/__init__.py b/tests/unittests/analyze/__init__.py new file mode 100644 index 00000000000..da6365a5941 --- /dev/null +++ b/tests/unittests/analyze/__init__.py @@ -0,0 +1 @@ +# This file is part of cloud-init. See LICENSE file for license information. diff --git a/tests/unittests/sources/azure/__init__.py b/tests/unittests/sources/azure/__init__.py new file mode 100644 index 00000000000..da6365a5941 --- /dev/null +++ b/tests/unittests/sources/azure/__init__.py @@ -0,0 +1 @@ +# This file is part of cloud-init. See LICENSE file for license information. diff --git a/tests/unittests/sources/helpers/__init__.py b/tests/unittests/sources/helpers/__init__.py new file mode 100644 index 00000000000..da6365a5941 --- /dev/null +++ b/tests/unittests/sources/helpers/__init__.py @@ -0,0 +1 @@ +# This file is part of cloud-init. See LICENSE file for license information. diff --git a/tests/unittests/sources/helpers/test_netlink.py b/tests/unittests/sources/helpers/test_netlink.py index 6aa0006a5bd..b68c8006c41 100644 --- a/tests/unittests/sources/helpers/test_netlink.py +++ b/tests/unittests/sources/helpers/test_netlink.py @@ -44,7 +44,7 @@ class TestCreateBoundNetlinkSocket(CiTestCase): def test_socket_error_on_create(self, m_socket): """create_bound_netlink_socket catches socket creation exception""" - """NetlinkCreateSocketError is raised when socket creation errors.""" + # NetlinkCreateSocketError is raised when socket creation errors. m_socket.side_effect = socket.error("Fake socket failure") with self.assertRaises(NetlinkCreateSocketError) as ctx_mgr: create_bound_netlink_socket()