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

Use str repr for param table html repr when __name__ does not exist #45

Merged
merged 2 commits into from
Aug 31, 2023

Conversation

nvaytet
Copy link
Member

@nvaytet nvaytet commented Aug 31, 2023

This uses the string representation for the html_repr column names in the case where .__name__ is not defined.
This is the case for python<3.10.

One slightly annoying thing is that when you have a parameter defined as Filename[Sample], in py310 the column header will be Filename, while in py39 it becomes Filename[Sample].

I could not use the string repr (with module name stripped) for all cases, because when you have a type defined simply as Filename = NewType('Filename', str), then the column name becomes something like new_type at 0x7f48681074c0>. In this case it is better to use the .__name__.
So we use the name when we can, and the string repr when .__name__ is not available.

Fixes #38

@nvaytet
Copy link
Member Author

nvaytet commented Aug 31, 2023

Maybe #31 is related?

@nvaytet nvaytet merged commit dec803d into main Aug 31, 2023
5 checks passed
@nvaytet nvaytet deleted the fix-html-repr branch August 31, 2023 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ParamTable._repr_html_ broken for Python 3.8 with generics
3 participants