mirror of
https://github.com/gradio-app/gradio.git
synced 2024-11-21 01:01:05 +08:00
Define Font.__repr__() to be printed in the doc in a readable format (#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>
This commit is contained in:
parent
c4ba832b31
commit
891d42e9ba
5
.changeset/green-forks-float.md
Normal file
5
.changeset/green-forks-float.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"gradio": patch
|
||||
---
|
||||
|
||||
fix:Define Font.__repr__() to be printed in the doc in a readable format
|
@ -40,6 +40,12 @@ class Font:
|
||||
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)):
|
||||
|
Loading…
Reference in New Issue
Block a user