Skip to content

Commit

Permalink
rm inline comment type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
rkingsbury committed Jun 27, 2023
1 parent 74f916c commit 25480ce
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/maggma/api/query_operator/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def query(
),
) -> STORE_PARAMS:

crit = {} # type: dict
crit: dict = {}

if state:
s_dict = {"$expr": {"$eq": [{"$arrayElemAt": ["$state", -1]}, state.value]}} # type: ignore
Expand Down
2 changes: 1 addition & 1 deletion src/maggma/api/resource/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def generate_query_pipeline(query: dict, store: Store):
sorting = query.get("sort", False)

if sorting:
sort_dict = {"$sort": {}} # type: dict
sort_dict:dict = {"$sort": {}}
sort_dict["$sort"].update(query["sort"])
sort_dict["$sort"].update({store.key: 1}) # Ensures sort by key is last in dict to fix determinacy

Expand Down
4 changes: 2 additions & 2 deletions src/maggma/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ def api_sanitize(
fields_to_leave: list of strings for model fields as "model__name__.field"
"""

models = [
models: List[Type[BaseModel]] = [
model
for model in get_flat_models_from_model(pydantic_model)
if issubclass(model, BaseModel)
] # type: List[Type[BaseModel]]
]

fields_to_leave = fields_to_leave or []
fields_tuples = [f.split(".") for f in fields_to_leave]
Expand Down
8 changes: 4 additions & 4 deletions src/maggma/builders/projection_builder.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from copy import deepcopy
from datetime import datetime
from itertools import chain
from typing import Dict, Iterable, List, Union
from typing import Dict, Iterable, List, Union, Set

from pydash import get

Expand Down Expand Up @@ -128,7 +128,7 @@ def get_items(self) -> Iterable:
if len(self.query_by_key) > 0:
keys = self.query_by_key
else:
unique_keys = set() # type: Set
unique_keys: Set = set()
for store in self.sources:
store_keys = store.distinct(field=store.key)
unique_keys.update(store_keys)
Expand Down Expand Up @@ -217,7 +217,7 @@ def process_item(self, items: Union[List, Iterable]) -> List[Dict]:
"""
self.logger.info("Processing items: sorting by key values...")
key = self.target.key
items_sorted_by_key = {} # type: Dict
items_sorted_by_key: Dict = {}
for i in items:
key_value = i[key]
if key_value not in items_sorted_by_key.keys():
Expand All @@ -227,7 +227,7 @@ def process_item(self, items: Union[List, Iterable]) -> List[Dict]:
items_for_target = []
for k, i_sorted in items_sorted_by_key.items():
self.logger.debug("Combined items for {}: {}".format(key, k))
target_doc = {} # type: Dict
target_doc: Dict = {}
for i in i_sorted:
target_doc.update(i)
# last modification is adding key value avoid overwriting
Expand Down
4 changes: 2 additions & 2 deletions src/maggma/core/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import logging
from abc import ABCMeta, abstractmethod
from typing import Any, Dict, Iterable, List, Union
from typing import Any, Dict, Iterable, List, Union, Optional

from monty.json import MontyDecoder, MSONable

Expand Down Expand Up @@ -41,7 +41,7 @@ def __init__(
self.sources = sources if isinstance(sources, list) else [sources]
self.targets = targets if isinstance(targets, list) else [targets]
self.chunk_size = chunk_size
self.total = None # type: Optional[int]
self.total: Optional[int] = None
self.logger = logging.getLogger(type(self).__name__)
self.logger.addHandler(logging.NullHandler())

Expand Down
6 changes: 3 additions & 3 deletions src/maggma/stores/compound_stores.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
""" Special stores that combine underlying Stores together """
from datetime import datetime
from itertools import groupby
from typing import Dict, Iterator, List, Optional, Tuple, Union
from typing import Dict, Iterator, List, Optional, Tuple, Union, Any

from pydash import set_
from pymongo import MongoClient
Expand Down Expand Up @@ -48,7 +48,7 @@ def __init__(
self.port = port
self.username = username
self.password = password
self._coll = None # type: Any
self._coll: Any = None
self.main = main or collection_names[0]
self.merge_at_root = merge_at_root
self.mongoclient_kwargs = mongoclient_kwargs or {}
Expand Down Expand Up @@ -265,7 +265,7 @@ def groupby(
)
if not isinstance(keys, list):
keys = [keys]
group_id = {} # type: Dict[str,Any]
group_id: Dict[str,Any] = {}
for key in keys:
set_(group_id, key, "${}".format(key))
pipeline.append({"$group": {"_id": group_id, "docs": {"$push": "$$ROOT"}}})
Expand Down

0 comments on commit 25480ce

Please sign in to comment.