Skip to content

Commit

Permalink
🐛 fix typing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
YousefEZ committed Aug 11, 2024
1 parent 01e22b8 commit a2c62e2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
7 changes: 4 additions & 3 deletions qalib/translators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
M = TypeVar("M")
N = TypeVar("N")
P = ParamSpec("P")
I = TypeVar("I", bound=discord.ui.Item, covariant=True)

Callback = Callable[[discord.ui.Item, discord.Interaction], Awaitable[None]]
Callback = Callable[[I, discord.Interaction], Awaitable[None]]


@dataclass
Expand Down Expand Up @@ -74,7 +75,7 @@ def as_edit(self) -> EditContextMessage:
suppress=self.suppress_embeds,
delete_after=self.delete_after,
allowed_mentions=self.allowed_mentions,
view=self.view
view=self.view,
)


Expand All @@ -94,7 +95,7 @@ def as_edit(self) -> InteractionEditMessage:
attachments=self.files,
delete_after=self.delete_after,
allowed_mentions=self.allowed_mentions,
view=self.view
view=self.view,
)


Expand Down
30 changes: 20 additions & 10 deletions qalib/translators/xml/embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ def colour(self) -> discord.Colour | int:
Returns (Optional[int]): An integer containing the raw color.
"""
return make_colour(self.get_element_text(self._raw_embed.find("color")) or self.get_element_text(
self._raw_embed.find("colour")))
return make_colour(
self.get_element_text(self._raw_embed.find("color"))
or self.get_element_text(self._raw_embed.find("colour"))
)


class XMLEmbedAdapter(XMLBaseEmbedAdapter, EmbedAdapter):
Expand All @@ -154,14 +156,18 @@ def fields(self) -> List[Field]:
Returns (List[dict]): A list of dictionaries containing the raw fields.
"""
fields_element = self._raw_embed.find("fields")
return [] if fields_element is None else [
{
"name": filter_tabs(self.get_element_text(field.find("name"))),
"value": filter_tabs(self.get_element_text(field.find("value"))),
"inline": field.get("inline", "").lower() == "true",
}
for field in fields_element.findall("field")
]
return (
[]
if fields_element is None
else [
{
"name": filter_tabs(self.get_element_text(field.find("name"))),
"value": filter_tabs(self.get_element_text(field.find("value"))),
"inline": field.get("inline", "").lower() == "true",
}
for field in fields_element.findall("field")
]
)


class XMLExpansiveEmbedAdapter(XMLBaseEmbedAdapter, ExpansiveEmbedAdapter):
Expand All @@ -170,6 +176,10 @@ def __init__(self, embed: ElementTree.Element, page_number_key: Optional[str] =
super().__init__(embed)
ExpansiveEmbedAdapter.__init__(self, page_number_key)

@property
def fields(self) -> List[Field]:
return [self.field]

Check warning on line 181 in qalib/translators/xml/embed.py

View check run for this annotation

Codecov / codecov/patch

qalib/translators/xml/embed.py#L181

Added line #L181 was not covered by tests

@property
def field(self) -> Field:
"""Renders the field from an ElementTree.Element.
Expand Down

0 comments on commit a2c62e2

Please sign in to comment.