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

[BUG] Literal types printed with HTML escape chars #228

Closed
yajo opened this issue Feb 9, 2021 · 4 comments · Fixed by #241
Closed

[BUG] Literal types printed with HTML escape chars #228

yajo opened this issue Feb 9, 2021 · 4 comments · Fixed by #241
Labels
bug Something isn't working

Comments

@yajo
Copy link

yajo commented Feb 9, 2021

Describe the bug
Prints 'git' instead of "git".

To Reproduce
I have a @cached_property defined like this:

@dataclass
class Template:
    """Object that represents a template and its current state.

    See [configuring a template][configuring-a-template].
    """

    @cached_property
    def vcs(self) -> Optional[Literal["git"]]:
        """Get VCS system used by the template, if any."""
        if get_repo(self.url):
            return "git"

Expected behavior
Print "git" instead.

Screenshots
imagen

System (please complete the following information):

Additional context
Observable on copier-org/copier@76018a7 from copier-org/copier#314.

@pawamoy
Copy link
Member

pawamoy commented Feb 9, 2021

Thanks for the report. I didn't have the chance to play with Literal yet, I'll add tests and fix that 🙂
However it is more a mkdocstrings issue rather than a pytkdocs one. (EDIT: moved to mkdocstrings repo)

@yajo
Copy link
Author

yajo commented Feb 9, 2021

I'm giving you a lot of work for just one PR 😅

@pawamoy
Copy link
Member

pawamoy commented Feb 9, 2021

Haha it's fine 😄 thanks a lot for reporting all these!

@pawamoy
Copy link
Member

pawamoy commented Feb 9, 2021

Probably this should do:

--- a/src/mkdocstrings/templates/python/material/attribute.html
+++ b/src/mkdocstrings/templates/python/material/attribute.html
@@ -23,7 +23,7 @@
 
         {% filter highlight(language="python", inline=True) %}
           {% if show_full_path %}{{ attribute.path }}{% else %}{{ attribute.name }}{% endif %}
-          {% if attribute.type %}: {{ attribute.type }}{% endif %}
+          {% if attribute.type %}: {{ attribute.type|safe }}{% endif %}
         {% endfilter %}
 
         {% with properties = attribute.properties %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants