Skip to content

Commit 2100483

Browse files
contribs client bugfixes
1 parent 5bdefe4 commit 2100483

3 files changed

Lines changed: 28 additions & 4 deletions

File tree

mp_api/client/contribs/_types.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,36 @@ def from_dict(cls, dct: dict) -> Self:
316316
return cls((k, v) for k, v in dct.items() if k in keys)
317317

318318

319+
"""
320+
The following type annotations are only used in type checking
321+
(mypy) the ContribsClient.get_all_ids function.
322+
This function has highly hetereogeneous output and these
323+
represent the intermediate and final data structures returned
324+
by that function.
325+
326+
They **shouldn't** have to be used elsewhere.
327+
"""
328+
319329
ComponentIdSets = dict[str, set[str]]
330+
"""Use only when type checking of ContribsClient.get_all_ids(...,fmt="sets")."""
331+
320332
ProjectIdSets = dict[str, set[str] | ComponentIdSets]
333+
"""Use only when type checking of ContribsClient.get_all_ids(...,fmt="sets")."""
334+
321335
AllIdSets = dict[str, ProjectIdSets]
336+
"""Use only when type checking of ContribsClient.get_all_ids(...,fmt="sets")."""
322337

323338
ComponentNameMap = dict[str, dict[str, str]]
339+
"""Use only when type checking of ContribsClient.get_all_ids(...,fmt="map")."""
340+
324341
IdentifierLeaf = dict[str, str | ComponentNameMap]
342+
"""Use only when type checking of ContribsClient.get_all_ids(...,fmt="map")."""
343+
325344
IdentifierBranch = dict[str, IdentifierLeaf]
345+
"""Use only when type checking of ContribsClient.get_all_ids(...,fmt="map")."""
346+
326347
ProjectIdMap = dict[str, IdentifierLeaf | IdentifierBranch]
348+
"""Use only when type checking of ContribsClient.get_all_ids(...,fmt="map")."""
349+
327350
AllIdMap = dict[str, ProjectIdMap]
351+
"""Use only when type checking of ContribsClient.get_all_ids(...,fmt="map")."""

mp_api/client/contribs/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
from mp_api.client.contribs._logger import MPCC_LOGGER, TqdmToLogger
5151
from mp_api.client.contribs._types import (
5252
Attachment,
53+
ComponentIdSets,
5354
MPCDict,
5455
MPCStructure,
5556
Table,
@@ -71,10 +72,9 @@
7172
from collections.abc import Generator, Iterable, Sequence
7273
from typing import Any
7374

74-
from mp_api.client.contribs.types import (
75+
from mp_api.client.contribs._types import (
7576
AllIdMap,
7677
AllIdSets,
77-
ComponentIdSets,
7878
IdentifierLeaf,
7979
ProjectIdSets,
8080
)
@@ -88,7 +88,7 @@
8888
warnings.filterwarnings("default", category=DeprecationWarning, module=__name__)
8989

9090

91-
def validate_email(email_string: str):
91+
def validate_email(email_string: str) -> AllIdMap:
9292
"""Validate user email address.
9393
9494
Args:

mp_api/client/contribs/schemas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,5 +372,5 @@ class QueryResult(_DictLikeAccess):
372372

373373
total_count: int
374374
total_pages: int
375-
data: list[BaseModel] | None = None
375+
data: list[ContribData] | None = None
376376
has_more: bool = False

0 commit comments

Comments
 (0)