Skip to content

Commit

Permalink
Define Font.__repr__() to be printed in the doc in a readable format (#…
Browse files Browse the repository at this point in the history
…5904)

* Define Font.__repr__() to be printed in the doc in a readable format

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
  • Loading branch information
whitphx and gradio-pr-bot committed Oct 16, 2023
1 parent c4ba832 commit 891d42e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/green-forks-float.md
@@ -0,0 +1,5 @@
---
"gradio": patch
---

fix:Define Font.__repr__() to be printed in the doc in a readable format
6 changes: 6 additions & 0 deletions gradio/themes/utils/fonts.py
Expand Up @@ -40,6 +40,12 @@ def stylesheet(self) -> str:
def __eq__(self, other: Font) -> bool:
return self.name == other.name and self.stylesheet() == other.stylesheet()

def __repr__(self) -> str:
klass = type(self)
class_repr = klass.__module__ + "." + klass.__qualname__
attrs = ", ".join([k + "=" + repr(v) for k, v in self.__dict__.items()])
return f"<{class_repr} ({attrs})>"


class GoogleFont(Font):
def __init__(self, name: str, weights: Iterable[int] = (400, 600)):
Expand Down

0 comments on commit 891d42e

Please sign in to comment.