diff --git a/python/ambassador/config/config.py b/python/ambassador/config/config.py index 1412835870..82ae8bcf87 100644 --- a/python/ambassador/config/config.py +++ b/python/ambassador/config/config.py @@ -132,9 +132,9 @@ def __init__(self, schema_dir_path: Optional[str] = None) -> None: self.schema_dir_path = schema_dir_path self.logger.debug("SCHEMA DIR %s" % os.path.abspath(self.schema_dir_path)) - self.k8s_status_updates: Dict[ - str, Tuple[str, str, Optional[Dict[str, Any]]] - ] = {} # Tuple is (name, namespace, status_json) + self.k8s_status_updates: Dict[str, Tuple[str, str, Optional[Dict[str, Any]]]] = ( + {} + ) # Tuple is (name, namespace, status_json) self.pod_labels: Dict[str, str] = {} self._reset() diff --git a/python/ambassador/diagnostics/diagnostics.py b/python/ambassador/diagnostics/diagnostics.py index de1f4f8924..17979e71f9 100644 --- a/python/ambassador/diagnostics/diagnostics.py +++ b/python/ambassador/diagnostics/diagnostics.py @@ -132,9 +132,9 @@ def __init__(self, diag: "Diagnostics", estat: EnvoyStats, request) -> None: self.clusters: Dict[str, DiagCluster] = {} # Envoy clusters self.routes: List[dict] = [] # Envoy routes self.element_keys: Dict[str, bool] = {} # Active element keys - self.ambassador_resources: Dict[ - str, str - ] = {} # Actually serializations of Ambassador config resources + self.ambassador_resources: Dict[str, str] = ( + {} + ) # Actually serializations of Ambassador config resources self.envoy_resources: Dict[str, dict] = {} # Envoy config resources def as_dict(self) -> Dict[str, Any]: diff --git a/python/ambassador/envoy/v3/v3listener.py b/python/ambassador/envoy/v3/v3listener.py index b2eda1f279..ac8b4e59c1 100644 --- a/python/ambassador/envoy/v3/v3listener.py +++ b/python/ambassador/envoy/v3/v3listener.py @@ -404,18 +404,18 @@ def access_log(self) -> List[dict]: access_log_obj["additional_request_headers_to_log"] = req_headers access_log_obj["additional_response_headers_to_log"] = resp_headers access_log_obj["additional_response_trailers_to_log"] = trailer_headers - access_log_obj[ - "@type" - ] = "type.googleapis.com/envoy.extensions.access_loggers.grpc.v3.HttpGrpcAccessLogConfig" + access_log_obj["@type"] = ( + "type.googleapis.com/envoy.extensions.access_loggers.grpc.v3.HttpGrpcAccessLogConfig" + ) access_log.append( {"name": "envoy.access_loggers.http_grpc", "typed_config": access_log_obj} ) else: # inherently TCP right now # tcp loggers do not support additional headers - access_log_obj[ - "@type" - ] = "type.googleapis.com/envoy.extensions.access_loggers.grpc.v3.TcpGrpcAccessLogConfig" + access_log_obj["@type"] = ( + "type.googleapis.com/envoy.extensions.access_loggers.grpc.v3.TcpGrpcAccessLogConfig" + ) access_log.append( {"name": "envoy.access_loggers.tcp_grpc", "typed_config": access_log_obj} ) @@ -500,9 +500,9 @@ def base_http_config(self) -> Dict[str, Any]: base_http_config["http_filters"].append(v3hf) if "use_remote_address" in self.config.ir.ambassador_module: - base_http_config[ - "use_remote_address" - ] = self.config.ir.ambassador_module.use_remote_address + base_http_config["use_remote_address"] = ( + self.config.ir.ambassador_module.use_remote_address + ) if self._l7_depth > 0: base_http_config["xff_num_trusted_hops"] = self._l7_depth @@ -546,24 +546,24 @@ def base_http_config(self) -> Dict[str, Any]: if "allow_chunked_length" in self.config.ir.ambassador_module: if self.config.ir.ambassador_module.allow_chunked_length != None: http_options = base_http_config.setdefault("http_protocol_options", {}) - http_options[ - "allow_chunked_length" - ] = self.config.ir.ambassador_module.allow_chunked_length + http_options["allow_chunked_length"] = ( + self.config.ir.ambassador_module.allow_chunked_length + ) if "preserve_external_request_id" in self.config.ir.ambassador_module: - base_http_config[ - "preserve_external_request_id" - ] = self.config.ir.ambassador_module.preserve_external_request_id + base_http_config["preserve_external_request_id"] = ( + self.config.ir.ambassador_module.preserve_external_request_id + ) if "forward_client_cert_details" in self.config.ir.ambassador_module: - base_http_config[ - "forward_client_cert_details" - ] = self.config.ir.ambassador_module.forward_client_cert_details + base_http_config["forward_client_cert_details"] = ( + self.config.ir.ambassador_module.forward_client_cert_details + ) if "set_current_client_cert_details" in self.config.ir.ambassador_module: - base_http_config[ - "set_current_client_cert_details" - ] = self.config.ir.ambassador_module.set_current_client_cert_details + base_http_config["set_current_client_cert_details"] = ( + self.config.ir.ambassador_module.set_current_client_cert_details + ) if self.config.ir.tracing: base_http_config["generate_request_id"] = True diff --git a/python/ambassador/envoy/v3/v3route.py b/python/ambassador/envoy/v3/v3route.py index 9707f70aa3..a96e1c3b1f 100644 --- a/python/ambassador/envoy/v3/v3route.py +++ b/python/ambassador/envoy/v3/v3route.py @@ -313,9 +313,9 @@ def __init__( ) self["_failed"] = True else: - runtime_fraction[ - "runtime_key" - ] = f"routing.traffic_shift.{mapping.cluster.envoy_name}" + runtime_fraction["runtime_key"] = ( + f"routing.traffic_shift.{mapping.cluster.envoy_name}" + ) match = {"case_sensitive": case_sensitive, "runtime_fraction": runtime_fraction} diff --git a/python/ambassador/envoy/v3/v3runtime.py b/python/ambassador/envoy/v3/v3runtime.py index 70c6df4047..5145eef894 100644 --- a/python/ambassador/envoy/v3/v3runtime.py +++ b/python/ambassador/envoy/v3/v3runtime.py @@ -51,9 +51,9 @@ def __init__(self, config: "V3Config") -> None: isinstance(rapid_reset_min_stream_lifetime, int) and rapid_reset_min_stream_lifetime > 0 ): - static_runtime_layer[ - "overload.premature_reset_min_stream_lifetime_seconds" - ] = rapid_reset_min_stream_lifetime + static_runtime_layer["overload.premature_reset_min_stream_lifetime_seconds"] = ( + rapid_reset_min_stream_lifetime + ) else: config.ir.logger.error( f"value: {rapid_reset_min_stream_lifetime} is invalid for Module field overload.premature_reset_min_stream_lifetime_seconds. must be an integer greater than zero" @@ -64,9 +64,9 @@ def __init__(self, config: "V3Config") -> None: ) if rapid_reset_total_streams: if isinstance(rapid_reset_total_streams, int) and rapid_reset_total_streams > 0: - static_runtime_layer[ - "overload.premature_reset_total_stream_count" - ] = rapid_reset_total_streams + static_runtime_layer["overload.premature_reset_total_stream_count"] = ( + rapid_reset_total_streams + ) else: config.ir.logger.error( f"value: {rapid_reset_total_streams} invalid for Module field overload.premature_reset_total_stream_count. must be an integer greater than zero" diff --git a/python/ambassador/fetch/dependency.py b/python/ambassador/fetch/dependency.py index 1e0d97a4b2..72935137e4 100644 --- a/python/ambassador/fetch/dependency.py +++ b/python/ambassador/fetch/dependency.py @@ -26,8 +26,7 @@ class Dependency(Protocol): without direct knowledge of where data is coming from. """ - def watt_key(self) -> str: - ... + def watt_key(self) -> str: ... class ServiceDependency(Dependency): @@ -76,11 +75,9 @@ def watt_key(self) -> str: class DependencyMapping(Protocol): - def __contains__(self, key: Type[D]) -> bool: - ... + def __contains__(self, key: Type[D]) -> bool: ... - def __getitem__(self, key: Type[D]) -> D: - ... + def __getitem__(self, key: Type[D]) -> D: ... class DependencyInjector: diff --git a/python/ambassador/fetch/ingress.py b/python/ambassador/fetch/ingress.py index a8ca117315..37ec8de3da 100644 --- a/python/ambassador/fetch/ingress.py +++ b/python/ambassador/fetch/ingress.py @@ -256,9 +256,9 @@ def _process(self, obj: KubernetesObject) -> None: "ambassador_id": obj.ambassador_id, "prefix": path_location, "prefix_exact": is_exact_prefix, - "precedence": 1 - if is_exact_prefix - else 0, # Make sure exact paths are evaluated before prefix + "precedence": ( + 1 if is_exact_prefix else 0 + ), # Make sure exact paths are evaluated before prefix "service": f"{service_name}.{obj.namespace}:{service_port}", } diff --git a/python/ambassador/ir/irhttpmapping.py b/python/ambassador/ir/irhttpmapping.py index 7eea649cc5..812922923f 100644 --- a/python/ambassador/ir/irhttpmapping.py +++ b/python/ambassador/ir/irhttpmapping.py @@ -216,9 +216,9 @@ def __init__( if "*" in hdr_value: # We can't call self.post_error() yet, because we're not initialized yet. So we cheat a bit # and defer the error for later. - new_args[ - "_deferred_error" - ] = f":authority exact-match '{hdr_value}' contains *, which cannot match anything." + new_args["_deferred_error"] = ( + f":authority exact-match '{hdr_value}' contains *, which cannot match anything." + ) ir.logger.debug( "IRHTTPMapping %s: self.host contains * (%s, :authority)", name, @@ -255,9 +255,9 @@ def __init__( if "*" in host: # We can't call self.post_error() yet, because we're not initialized yet. So we cheat a bit # and defer the error for later. - new_args[ - "_deferred_error" - ] = f"host exact-match {host} contains *, which cannot match anything." + new_args["_deferred_error"] = ( + f"host exact-match {host} contains *, which cannot match anything." + ) ir.logger.debug("IRHTTPMapping %s: self.host contains * (%s, host)", name, host) else: ir.logger.debug("IRHTTPMapping %s: self.host == %s (host)", name, self.host) diff --git a/python/tests/kat/abstract_tests.py b/python/tests/kat/abstract_tests.py index 1a574513e5..5eb9c4f3c0 100644 --- a/python/tests/kat/abstract_tests.py +++ b/python/tests/kat/abstract_tests.py @@ -81,7 +81,6 @@ def assert_default_errors(errors, include_ingress_errors=True): @abstract_test class AmbassadorTest(Test): - """ AmbassadorTest is a top level ambassador test. """ diff --git a/python/tests/unit/test_irratelimit.py b/python/tests/unit/test_irratelimit.py index 2b5ffc66ea..61d0ac51fc 100644 --- a/python/tests/unit/test_irratelimit.py +++ b/python/tests/unit/test_irratelimit.py @@ -228,9 +228,9 @@ def test_irratelimit_overrides(): ) config = _get_ratelimit_default_conf() - config["rate_limit_service"]["grpc_service"]["envoy_grpc"][ - "cluster_name" - ] = "cluster_{}_someotherns".format(SERVICE_NAME) + config["rate_limit_service"]["grpc_service"]["envoy_grpc"]["cluster_name"] = ( + "cluster_{}_someotherns".format(SERVICE_NAME) + ) config["timeout"] = "0.500s" config["domain"] = "otherdomain" config["failure_mode_deny"] = True