[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[tool.black]
line-length = 79
include = '(brpm|bddeb|\.py)$'

[tool.isort]
profile = "black"
line_length = 79
# We patch logging in main.py before certain imports
skip = ["cloudinit/cmd/main.py", ".tox", "packages", "tools"]

[tool.mypy]
follow_imports = "silent"
check_untyped_defs = true
warn_redundant_casts = true
warn_unused_ignores = true
warn_unreachable = true
exclude = []

[[tool.mypy.overrides]]
module = [
    "apport.*",
    "BaseHTTPServer",
    "configobj",
    "debconf",
    "httplib",
    "jsonpatch",
    "paramiko.*",
    "pip.*",
    "pycloudlib.*",
    "responses",
    "serial",
    "tests.integration_tests.user_settings",
    "uaclient.*",
]
ignore_missing_imports = true
no_implicit_optional = true

# See GH-5445
[[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.modules",
    "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.net.cmdline",
    "cloudinit.net.eni",
    "cloudinit.net.ephemeral",
    "cloudinit.net.freebsd",
    "cloudinit.net.netbsd",
    "cloudinit.net.network_manager",
    "cloudinit.net.network_state",
    "cloudinit.net.networkd",
    "cloudinit.net.sysconfig",
    "cloudinit.netinfo",
    "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.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",
    "tests.integration_tests.instances",
    "tests.unittests.analyze.test_show",
    "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_phone_home",
    "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_runcmd",
    "tests.unittests.config.test_cc_ssh",
    "tests.unittests.config.test_cc_ubuntu_autoinstall",
    "tests.unittests.config.test_cc_ubuntu_drivers",
    "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_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_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.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
# E, W, and F make up the entirety of default flake8
lint.select = [
    "D",   # pydocstyle
    "E",   # pycodestyle errors
    "W",   # pycodestyle warnings
    "F",   # pyflakes
    "T10", # flake8-debugger
    "ISC", # flake8-implicit-str-concat
    "ICN", # flake8-import-conventions
    "G",   # flake8-logging-format
    "PIE", # flake8-pie
    "Q",   # flake8-quotes
]
lint.ignore = [
    "D100", # docstring: public module
    "D101", # docstring: public class required
    "D102", # docstring: public method required
    "D103", # docstring: public function required
    "D107", # docstring: __init__ required
    "D104", # docstring: public package required
    "D105", # docstring: magic method required
    "D200", # docstring: one line docstring shouldn't wrap
    "D202", # docstring: blank line
    "D205", # docstring: 1 blank line between initial and summary
    "D209", # docstring: closing quotes -> separate line
    "D400", # docstring: end with a period
    "D401", # docstring: imperative mood
    "D402", # docstring: docstring shouldn't start with func signature
    "D403", # docstring: capitalized first line
    "E731", # Do not assign a `lambda` expression, use a `def`
]

[tool.ruff.lint.pydocstyle]
convention = "pep257"
