diff --git a/slo_generator/api/main.py b/slo_generator/api/main.py index 42371669..cfe0798b 100644 --- a/slo_generator/api/main.py +++ b/slo_generator/api/main.py @@ -98,11 +98,7 @@ def run_export(request): # Construct exporters block spec = {} - default_exporters = ( - config.get('default_exporters', []) - if config is not None - else [] - ) + default_exporters = config.get('default_exporters', []) cli_exporters = os.environ.get('EXPORTERS', None) if cli_exporters: cli_exporters = cli_exporters.split(',') @@ -193,7 +189,7 @@ def process_batch_req(request, data, config): headers['Authorization'] = request.headers['Authorization'] service_url = service_url.replace('http:', 'https:') # force HTTPS auth for url in urls: - if config is not None and 'pubsub_batch_handler' in config: + if 'pubsub_batch_handler' in config: LOGGER.info(f'Sending {url} to pubsub batch handler.') from google.cloud import pubsub_v1 # pylint: disable=C0415 exporter_conf = config.get('pubsub_batch_handler') diff --git a/slo_generator/backends/cloud_monitoring_mql.py b/slo_generator/backends/cloud_monitoring_mql.py index 10ccd5d6..4b4ab1ca 100644 --- a/slo_generator/backends/cloud_monitoring_mql.py +++ b/slo_generator/backends/cloud_monitoring_mql.py @@ -204,13 +204,11 @@ def query(self, query: str, window: int) -> List[TimeSeriesData]: 'query': formatted_query }) - timeseries: list - if self.client: - timeseries_pager: QueryTimeSeriesPager = ( - self.client.query_time_series(request) - ) - timeseries = list(timeseries_pager) # convert pager to flat list - LOGGER.debug(pprint.pformat(timeseries)) + timeseries_pager: QueryTimeSeriesPager = ( + self.client.query_time_series(request) + ) + timeseries: list = list(timeseries_pager) # convert pager to flat list + LOGGER.debug(pprint.pformat(timeseries)) return timeseries @staticmethod