-
Notifications
You must be signed in to change notification settings - Fork 3
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
Enable reporting unknown types #333
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Enable reporting unknown types for basedpyright. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,7 +55,7 @@ def visit_attributetabletitle_node(self: HTML5Translator, node: AttributeTableTi | |
|
||
|
||
def visit_attributetablebadge_node(self: HTML5Translator, node: AttributeTableBadge) -> None: | ||
attributes = { | ||
attributes: dict[str, Any] = { | ||
"class": "py-attribute-table-badge", | ||
"title": node["badge-type"], | ||
} | ||
|
@@ -153,7 +153,7 @@ def run(self) -> list[AttributeTablePlaceholder]: | |
def build_lookup_table(env: BuildEnvironment) -> dict[str, list[str]]: | ||
# Given an environment, load up a lookup table of | ||
# full-class-name: objects | ||
result = {} | ||
result: dict[str, list[str]] = {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But for these ones it's interesting to have type checking There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, in some cases, being forced to explicitly declare the annotations can be very helpful to the type checker, it is nice that this would now be a requirement, where types can't be easily inferred. |
||
domain = env.domains["py"] | ||
|
||
ignored = { | ||
|
@@ -285,11 +285,11 @@ def class_results_to_node(key: str, elements: Sequence[TableElement]) -> Attribu | |
|
||
def setup(app: Sphinx) -> dict[str, Any]: | ||
app.add_directive("attributetable", PyAttributeTable) | ||
app.add_node(AttributeTable, html=(visit_attributetable_node, depart_attributetable_node)) | ||
app.add_node(AttributeTableColumn, html=(visit_attributetablecolumn_node, depart_attributetablecolumn_node)) | ||
app.add_node(AttributeTableTitle, html=(visit_attributetabletitle_node, depart_attributetabletitle_node)) | ||
app.add_node(AttributeTableBadge, html=(visit_attributetablebadge_node, depart_attributetablebadge_node)) | ||
app.add_node(AttributeTableItem, html=(visit_attributetable_item_node, depart_attributetable_item_node)) | ||
app.add_node(AttributeTablePlaceholder) | ||
_ = app.connect("doctree-resolved", process_attributetable) | ||
app.add_node(AttributeTable, html=(visit_attributetable_node, depart_attributetable_node)) # pyright: ignore[reportUnknownMemberType] | ||
app.add_node(AttributeTableColumn, html=(visit_attributetablecolumn_node, depart_attributetablecolumn_node)) # pyright: ignore[reportUnknownMemberType] | ||
app.add_node(AttributeTableTitle, html=(visit_attributetabletitle_node, depart_attributetabletitle_node)) # pyright: ignore[reportUnknownMemberType] | ||
app.add_node(AttributeTableBadge, html=(visit_attributetablebadge_node, depart_attributetablebadge_node)) # pyright: ignore[reportUnknownMemberType] | ||
app.add_node(AttributeTableItem, html=(visit_attributetable_item_node, depart_attributetable_item_node)) # pyright: ignore[reportUnknownMemberType] | ||
app.add_node(AttributeTablePlaceholder) # pyright: ignore[reportUnknownMemberType] | ||
_ = app.connect("doctree-resolved", process_attributetable) # pyright: ignore[reportUnknownMemberType] | ||
return {"parallel_read_safe": True} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
from typing import NamedTuple | ||
|
||
import httpx | ||
from typing_extensions import override | ||
from typing_extensions import Any, override | ||
|
||
__all__ = [ | ||
"XSTSErrorType", | ||
|
@@ -67,7 +67,7 @@ def __init__(self, exc: httpx.HTTPStatusError): | |
@property | ||
def msg(self) -> str: | ||
"""Produce a message for this error.""" | ||
msg_parts = [] | ||
msg_parts: list[str] = [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I already have things like that all over the place in more-packets |
||
if self.err_type is not XSTSErrorType.UNKNOWN: | ||
msg_parts.append(f"{self.err_type.name}: {self.err_type.value!r}") | ||
else: | ||
|
@@ -96,7 +96,7 @@ async def xbox_auth(client: httpx.AsyncClient, microsoft_access_token: str, bedr | |
See :func:`~mcproto.auth.microsoft.oauth.full_microsoft_oauth` for info on ``microsoft_access_token``. | ||
""" | ||
# Obtain XBL token | ||
payload = { | ||
payload: dict[str, Any] = { | ||
"Properties": { | ||
"AuthMethod": "RPS", | ||
"SiteName": "user.auth.xboxlive.com", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see how these kind of type annotations are better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the thing is, pyright would otherwise mark this as
dict[str, Unknown]
and withUnknown
being banned, if a wildcard type is indeed what we want, it must be declared explicitly like this. That's also one of the reasons why these rules might be a bit too strict.