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

Modify Table repr #549

Closed
dantownsend opened this issue Jun 17, 2022 · 0 comments · Fixed by #550
Closed

Modify Table repr #549

dantownsend opened this issue Jun 17, 2022 · 0 comments · Fixed by #550
Labels
documentation Requires additional docs, or changes to the docs

Comments

@dantownsend
Copy link
Member

By default, the repr for a Python class type is something like:

>>> repr(MyTable)
<class 'my_app.tables.MyTable'>

It's a very common pattern in Piccolo and its sister libraries to have Table class types as default values:

# `SessionsBase` is a `Table` subclass:
def session_auth(
    session_table: t.Type[SessionsBase] = SessionsBase
):
    ...

This looks terrible in Sphinx's autodoc output, as Python's default repr contains angled brackets, which breaks the HTML output.

Screenshot 2022-06-17 at 15 46 14

So we just need to output the name instead. The user can still easily find which module a Table subclass belongs to by using MyTable.__module__.

@dantownsend dantownsend added the documentation Requires additional docs, or changes to the docs label Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Requires additional docs, or changes to the docs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant