Skip to content

Commit

Permalink
make lint happy again
Browse files Browse the repository at this point in the history
Signed-off-by: Alice-Lilith <a.wasko@ngrok.com>
  • Loading branch information
Alice-Lilith committed Nov 27, 2024
1 parent c2e0a88 commit b98d132
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 55 deletions.
6 changes: 3 additions & 3 deletions python/ambassador/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
6 changes: 3 additions & 3 deletions python/ambassador/diagnostics/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
42 changes: 21 additions & 21 deletions python/ambassador/envoy/v3/v3listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions python/ambassador/envoy/v3/v3route.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
12 changes: 6 additions & 6 deletions python/ambassador/envoy/v3/v3runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
9 changes: 3 additions & 6 deletions python/ambassador/fetch/dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions python/ambassador/fetch/ingress.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
}

Expand Down
12 changes: 6 additions & 6 deletions python/ambassador/ir/irhttpmapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion python/tests/kat/abstract_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down
6 changes: 3 additions & 3 deletions python/tests/unit/test_irratelimit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b98d132

Please sign in to comment.