Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(typing): Resolve misc type ignores in schemapi.py #3545

Merged
merged 6 commits into from
Aug 18, 2024
Merged
Changes from 1 commit
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
Next Next commit
chore(typing): Add pyright ignores in schemapi.py
dangotbanned committed Aug 18, 2024
commit 22bf6bbb4e12ec9789242f1df45f88c0723cd5e1
8 changes: 4 additions & 4 deletions tools/schemapi/schemapi.py
Original file line number Diff line number Diff line change
@@ -1325,7 +1325,7 @@ def from_dict(
tp: None = ...,
schema: Any = ...,
rootschema: None = ...,
default_class: type[TSchemaBase] = ...,
default_class: type[TSchemaBase] = ..., # pyright: ignore[reportInvalidTypeVarUse]
) -> TSchemaBase: ...
@overload
def from_dict(
@@ -1378,7 +1378,7 @@ def from_dict(
current_schema = schema
root_schema = rootschema or current_schema
matches = self.class_dict[self.hash_schema(current_schema)]
target_tp = matches[0] if matches else default_class
target_tp = matches[0] if matches else default_class # pyright: ignore[reportAssignmentType]
else:
msg = "Must provide either `tp` or `schema`, but not both."
raise ValueError(msg)
@@ -1400,13 +1400,13 @@ def from_dict(
# TODO: handle schemas for additionalProperties/patternProperties
props: dict[str, Any] = resolved.get("properties", {})
kwds = {
k: (from_dict(v, schema=props[k]) if k in props else v)
k: (from_dict(v, schema=props[k]) if k in props else v) # pyright: ignore[reportCallIssue]
for k, v in dct.items()
}
return target_tp(**kwds)
elif _is_list(dct):
item_schema: dict[str, Any] = resolved.get("items", {})
return target_tp([from_dict(k, schema=item_schema) for k in dct])
return target_tp([from_dict(k, schema=item_schema) for k in dct]) # pyright: ignore[reportCallIssue]
else:
# NOTE: Unsure what is valid here
return target_tp(dct)