# Buggy code
def _check_conf_types(self, conf, conf_types):
    """Check that conf value is of the correct type."""
    for conf_key, conf_value in conf.items():
        test_config_condition(
            conf_key not in conf_types,
            "%s field unknown in %s (known types %s)"
            % (conf_key, self._id, conf_types),
        )
        if conf_value is not None:
            conf_type = conf_types[conf_key]
            test_config_condition(
                not isinstance(conf_value, conf_type),
                "%s value %s must be %s not %s"
                % (conf_key, conf_value, conf_type, type(conf_value)),
            )  # pytype: disable=invalid-typevar


# Traceback (AttributeError)
Oct 30 02:49:35 faucet.exception ERROR    Unhandled exception, killing RYU
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/faucet/valve_util.py", line 34, in __koe
func(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/faucet/faucet.py", line 156, in reload_config
time.time(), self.config_file, delete_dp=self._delete_deconfigured_dp)
File "/usr/lib/python3.6/site-packages/faucet/valves_manager.py", line 139, in request_reload_configs
self.load_configs(now, new_config_file, delete_dp=delete_dp)
File "/usr/lib/python3.6/site-packages/faucet/valves_manager.py", line 108, in load_configs
new_dps = self.parse_configs(new_config_file)
File "/usr/lib/python3.6/site-packages/faucet/valves_manager.py", line 88, in parse_configs
new_config_hashes, new_dps = dp_parser(new_config_file, self.logname)
File "/usr/lib/python3.6/site-packages/faucet/config_parser.py", line 51, in dp_parser
config_hashes, dps = _config_parser_v2(config_file, logname)
File "/usr/lib/python3.6/site-packages/faucet/config_parser.py", line 213, in _config_parser_v2
top_confs['vlans'])
File "/usr/lib/python3.6/site-packages/faucet/config_parser.py", line 177, in _dp_parser_v2
for dp_key, dp_conf in dps_conf.items()]
File "/usr/lib/python3.6/site-packages/faucet/config_parser.py", line 177, in <listcomp>
for dp_key, dp_conf in dps_conf.items()]
File "/usr/lib/python3.6/site-packages/faucet/config_parser.py", line 161, in _parse_dp
acl = ACL(acl_key, dp_id, acl_conf)
File "/usr/lib/python3.6/site-packages/faucet/acl.py", line 118, in __init__
super(ACL, self).__init__(_id, dp_id, conf)
File "/usr/lib/python3.6/site-packages/faucet/conf.py", line 54, in __init__
self.check_config()
File "/usr/lib/python3.6/site-packages/faucet/acl.py", line 127, in check_config
self._check_conf_types(rule, self.rule_types)
File "/usr/lib/python3.6/site-packages/faucet/conf.py", line 76, in _check_conf_types
for conf_key, conf_value in conf.items():
AttributeError: 'NoneType' object has no attribute 'items'

# Fixed code
def _check_conf_types(self, conf, conf_types):
    """Check that conf value is of the correct type."""
    test_config_condition(
        not isinstance(conf, dict),
        ("Conf object must be type %s not %s" % (dict, type(conf))),
    )
    for conf_key, conf_value in conf.items():
        test_config_condition(
            conf_key not in conf_types,
            "%s field unknown in %s (known types %s)"
            % (conf_key, self._id, conf_types),
        )
        if conf_value is not None:
            conf_type = conf_types[conf_key]
            test_config_condition(
                not isinstance(conf_value, conf_type),
                "%s value %s must be %s not %s"
                % (conf_key, conf_value, conf_type, type(conf_value)),
            )  # pytype: disable=invalid-typevar