Skip to content

Commit

Permalink
Merge pull request #116 from mrcljx/avoid-any
Browse files Browse the repository at this point in the history
feat(typing): Prefer `object` over `Any`
  • Loading branch information
bahlo authored Sep 7, 2024
2 parents 7053320 + 6d9e5d5 commit c671049
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
12 changes: 7 additions & 5 deletions axiom/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .util import Util
from enum import Enum
from humps import decamelize
from typing import Optional, List, Dict, Any
from typing import Optional, List, Dict
from logging import getLogger
from dataclasses import dataclass, field, asdict
from datetime import datetime
Expand Down Expand Up @@ -274,7 +274,7 @@ def query(self, apl: str, opts: Optional[AplOptions] = None) -> QueryResult:
result.savedQueryID = query_id
return result

def _prepare_query_options(self, opts: QueryOptions) -> Dict[str, Any]:
def _prepare_query_options(self, opts: QueryOptions) -> Dict[str, object]:
"""returns the query options as a Dict, handles any renaming for key fields."""
if opts is None:
return {}
Expand All @@ -290,7 +290,9 @@ def _prepare_query_options(self, opts: QueryOptions) -> Dict[str, Any]:

return params

def _prepare_ingest_options(self, opts: Optional[IngestOptions]) -> Dict[str, Any]:
def _prepare_ingest_options(
self, opts: Optional[IngestOptions]
) -> Dict[str, object]:
"""the query params for ingest api are expected in a format
that couldn't be defined as a variable name because it has a dash.
As a work around, we create the params dict manually."""
Expand All @@ -308,7 +310,7 @@ def _prepare_ingest_options(self, opts: Optional[IngestOptions]) -> Dict[str, An

return params

def _prepare_apl_options(self, opts: Optional[AplOptions]) -> Dict[str, Any]:
def _prepare_apl_options(self, opts: Optional[AplOptions]) -> Dict[str, object]:
"""Prepare the apl query options for the request."""
params = {"format": AplResultFormat.Legacy.value}

Expand All @@ -320,7 +322,7 @@ def _prepare_apl_options(self, opts: Optional[AplOptions]) -> Dict[str, Any]:

def _prepare_apl_payload(
self, apl: str, opts: Optional[AplOptions]
) -> Dict[str, Any]:
) -> Dict[str, object]:
"""Prepare the apl query options for the request."""
params = {}
params["apl"] = apl
Expand Down
8 changes: 4 additions & 4 deletions axiom/query/result.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass, field
from datetime import datetime, timedelta
from typing import List, Dict, Any, Optional
from typing import List, Dict, Optional
from enum import Enum

from .query import QueryLegacy
Expand Down Expand Up @@ -87,7 +87,7 @@ class Entry:
_rowId: str
# contains the raw data of the event (with filters and aggregations
# applied).
data: Dict[str, Any]
data: Dict[str, object]


@dataclass
Expand All @@ -96,7 +96,7 @@ class EntryGroupAgg:

# alias is the aggregations alias. If it wasn't specified at query time, it
# is the uppercased string representation of the aggregation operation.
value: Any
value: object
op: str = field(default="")
# value is the result value of the aggregation.

Expand All @@ -108,7 +108,7 @@ class EntryGroup:
# the unique id of the group.
id: int
# group maps the fieldnames to the unique values for the entry.
group: Dict[str, Any]
group: Dict[str, object]
# aggregations of the group.
aggregations: List[EntryGroupAgg]

Expand Down
2 changes: 1 addition & 1 deletion tests/test_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os

import unittest
from typing import List, Dict, Any, Optional
from typing import List, Dict, Optional
from logging import getLogger
from requests.exceptions import HTTPError
from datetime import timedelta
Expand Down
4 changes: 2 additions & 2 deletions tests/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os

import unittest
from typing import List, Dict, Any
from typing import List, Dict
from logging import getLogger
from requests.exceptions import HTTPError
from datetime import timedelta
Expand All @@ -17,7 +17,7 @@

class TestDatasets(unittest.TestCase):
dataset_name: str
events: List[Dict[str, Any]]
events: List[Dict[str, object]]
client: Client
events_time_format = "%d/%b/%Y:%H:%M:%S +0000"

Expand Down

0 comments on commit c671049

Please sign in to comment.