From 943d26da20246e6ff1355127d86e44863da6ade7 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Wed, 18 Sep 2024 21:59:03 -0400 Subject: [PATCH] Add initial mypy job Change-Id: I6a37421f324c76d30b1044f974066b0db0bb359d --- mypy.ini | 85 +++++++++++++++++++++++++++++++++++++++++++++ tox.ini | 8 ++++- zuul.d/base.yaml | 29 ++++++++++++++++ zuul.d/project.yaml | 1 + 4 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 mypy.ini diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 00000000000..66fa6ba8dd3 --- /dev/null +++ b/mypy.ini @@ -0,0 +1,85 @@ +# Config file options: https://mypy.readthedocs.io/en/stable/config_file.html + +[mypy] +incremental = True +pretty = True +show_error_context = True +show_column_numbers = True +warn_unused_ignores = True +# remove gradually as progress is made +disable_error_code = import-untyped,var-annotated,import-not-found + +# honor excludes by not following there through imports +follow_imports = silent + +# NOTE: Gradually enable type checking for each package. +# Finally, when the whole repo is migrated this option can be deleted +# and rules applied to the whole repo. +exclude = (?x)( + ^neutron/agent/linux/dhcp.py + | ^neutron/agent/metadata/agent.py$ + | ^neutron/agent/metadata/driver.py$ + | ^neutron/agent/ovn/extensions/metadata.py$ + | ^neutron/agent/ovn/metadata/driver.py$ + | ^neutron/agent/ovn/metadata/server.py$ + | ^neutron/agent/securitygroups_rpc.py$ + | ^neutron/api/rpc/callbacks/version_manager.py$ + | ^neutron/db/l3_dvr_db.py$ + | ^neutron/db/l3_hamode_db.py$ + | ^neutron/db/migration/alembic_migrations/env.py$ + | ^neutron/extensions/tagging.py$ + | ^neutron/manager.py$ + | ^neutron/objects/address_group.py$ + | ^neutron/objects/address_scope.py$ + | ^neutron/objects/agent.py$ + | ^neutron/objects/auto_allocate.py$ + | ^neutron/objects/conntrack_helper.py$ + | ^neutron/objects/flavor.py$ + | ^neutron/objects/floatingip.py$ + | ^neutron/objects/ipam.py$ + | ^neutron/objects/l3_hamode.py$ + | ^neutron/objects/l3agent.py$ + | ^neutron/objects/local_ip.py$ + | ^neutron/objects/logapi/logging_resource.py$ + | ^neutron/objects/metering.py$ + | ^neutron/objects/ndp_proxy.py$ + | ^neutron/objects/network.py$ + | ^neutron/objects/network_segment_range.py$ + | ^neutron/objects/plugins/ml2/flatallocation.py$ + | ^neutron/objects/plugins/ml2/geneveallocation.py$ + | ^neutron/objects/plugins/ml2/greallocation.py$ + | ^neutron/objects/plugins/ml2/vlanallocation.py$ + | ^neutron/objects/plugins/ml2/vxlanallocation.py$ + | ^neutron/objects/port/extensions/allowedaddresspairs.py$ + | ^neutron/objects/port/extensions/data_plane_status.py$ + | ^neutron/objects/port/extensions/extra_dhcp_opt.py$ + | ^neutron/objects/port/extensions/port_device_profile.py$ + | ^neutron/objects/port/extensions/port_hardware_offload_type.py$ + | ^neutron/objects/port/extensions/port_hints.py$ + | ^neutron/objects/port/extensions/port_numa_affinity_policy.py$ + | ^neutron/objects/port/extensions/port_security.py$ + | ^neutron/objects/port/extensions/port_trusted.py$ + | ^neutron/objects/port/extensions/uplink_status_propagation.py$ + | ^neutron/objects/port_forwarding.py$ + | ^neutron/objects/ports.py$ + | ^neutron/objects/provisioning_blocks.py$ + | ^neutron/objects/qos/binding.py$ + | ^neutron/objects/qos/policy.py$ + | ^neutron/objects/qos/rule.py$ + | ^neutron/objects/quota.py$ + | ^neutron/objects/router.py$ + | ^neutron/objects/securitygroup.py$ + | ^neutron/objects/securitygroup_default_rules.py$ + | ^neutron/objects/servicetype.py$ + | ^neutron/objects/subnet.py$ + | ^neutron/objects/subnetpool.py$ + | ^neutron/objects/tag.py$ + | ^neutron/objects/trunk.py$ + | ^neutron/plugins/ml2/drivers/linuxbridge/agent/arp_protect.py$ + | ^neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/commands.py$ + | ^neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovn_client.py$ + | ^neutron/plugins/ml2/drivers/ovn/mech_driver/ovsdb/ovsdb_monitor.py$ + | ^neutron/services/logapi/drivers/openvswitch/ovs_firewall_log.py$ + | ^neutron/tests/$ + ) + diff --git a/tox.ini b/tox.ini index c61920a73f3..5cf09527564 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = docs,py3,pep8 +envlist = docs,py3,pep8,mypy minversion = 3.18.0 skipsdist = False ignore_basepython_conflict = True @@ -121,6 +121,12 @@ commands = stestr run --slowest --concurrency 2 --exclude-regex neutron.tests.fullstack.test_securitygroup.TestSecurityGroupsSameNetwork.test_securitygroup {posargs} stestr run --slowest --combine --concurrency 1 neutron.tests.fullstack.test_securitygroup.TestSecurityGroupsSameNetwork.test_securitygroup {posargs} +[testenv:mypy] +deps = + {[testenv]deps} + mypy==1.11.2 +commands = mypy --config-file ./mypy.ini neutron + [testenv:releasenotes] description = Build release note documentation in HTML format. diff --git a/zuul.d/base.yaml b/zuul.d/base.yaml index 8ba236acda0..d3b6505f55f 100644 --- a/zuul.d/base.yaml +++ b/zuul.d/base.yaml @@ -113,6 +113,35 @@ - ^zuul.d/tempest-multinode.yaml - ^zuul.d/tempest-singlenode.yaml +- job: + name: neutron-tox-mypy + parent: openstack-tox + vars: + tox_envlist: mypy + voting: false + irrelevant-files: + - ^\.pylintrc$ + - ^releasenotes/.*$ + - ^doc/.*$ + - ^setup.cfg$ + - ^plugin.spec$ + - ^tools/ovn_migration/.*$ + - ^.*\.conf\.sample$ + - ^.*\.rst$ + - ^neutron/locale/.*$ + - ^vagrant/.*$ + - ^devstack/.*$ + - ^playbooks/.*$ + - ^roles/.*$ + - ^rally-jobs/.*$ + # Ignore everything except for zuul.d/project.yaml + - ^zuul.d/base.yaml + - ^zuul.d/grenade.yaml + - ^zuul.d/job-templates.yaml + - ^zuul.d/rally.yaml + - ^zuul.d/tempest-multinode.yaml + - ^zuul.d/tempest-singlenode.yaml + - job: name: neutron-fullstack-with-uwsgi parent: neutron-fullstack diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index 6b437886529..9414dd6c4d9 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -18,6 +18,7 @@ - neutron-skip-level-jobs check: jobs: + - neutron-tox-mypy - neutron-functional-with-uwsgi - neutron-fullstack-with-uwsgi - neutron-ovs-grenade-multinode