Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions drow/parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union, TypeVar, Generic, TypeAlias
from typing import Union, TypeVar, Generic, TypeAlias, Never

from .annotation import (
SuccessResponse, ErrorResponse,
Expand Down Expand Up @@ -50,8 +50,6 @@ def parse_query_response(self, resp: QueryResponse) -> QueryResult[T]:
if resp["status"] == "error":
self.parse_error(resp)

assert resp["status"] == "success", resp

data = resp["data"]

if data["resultType"] == "string":
Expand All @@ -65,7 +63,7 @@ def parse_query_response(self, resp: QueryResponse) -> QueryResult[T]:

raise ParseError(f'unknown result type: {data["resultType"]}')

def parse_error(self, resp: ErrorResponse) -> None:
def parse_error(self, resp: ErrorResponse) -> Never:
raise PrometheusError(
f'error {resp["errorType"]}: {resp["error"]}'
)
Expand All @@ -90,11 +88,7 @@ def parse_query_range_response(
if resp["status"] == "error":
self.parse_error(resp)

assert resp["status"] == "success", resp

data = resp["data"]
assert data["resultType"] == "matrix", resp

return self.parse_matrix(data)

def parse_vector(self, data: VectorData) -> InstantVector[T]:
Expand All @@ -121,8 +115,6 @@ def parse_query_value_response(self, resp: QueryResponse) -> T:
if resp["status"] == "error":
self.parse_error(resp)

assert resp["status"] == "success", resp

data = resp["data"]

if data["resultType"] == "string":
Expand Down