Skip to content
Discussion options

You must be logged in to vote

Indeed, this is not a FastAPI or Starlette issue. Debugging even further, it seems there's something funny happening with jinja2. This example demonstrates the somewhat strange behavior

import jinja2

class Prop:
    @property
    def no_crash(self) -> str:
        return 'Hello World'

    @property
    def should_crash(self) -> str:
        return self.item

class NoProp:
    def no_crash(self) -> str:
        return 'Hello World'

    def should_crash(self) -> str:
        return self.item


environment = jinja2.Environment()
template_noprop = environment.from_string("""{{ item.no_crash() }}

{{ item.should_crash() }}""")
template_prop = environment.from_string("""{{ item.no_crash }}

{…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@kratsg
Comment options

@kratsg
Comment options

Answer selected by kratsg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem
1 participant