Skip to content

Missing node attributes for jinja2 #3197

@The-Compiler

Description

@The-Compiler

It looks like the stubs for jinja2 are missing attributes for its node objects.

For example, this works fine:

import jinja2
import jinja2.nodes

template = jinja2.Environment().parse('{{ foo.bar }}')
nodes = list(template.iter_child_nodes())
nodes = list(nodes[0].iter_child_nodes())
node = nodes[0]
assert isinstance(node, jinja2.nodes.Getattr)
print(node.attr)
print(node.node)

but mypy says:

x.py:9: error: "Getattr" has no attribute "attr"
x.py:10: error: "Getattr" has no attribute "node"

because of:

class Getattr(Expr):
fields: Any
def as_const(self, eval_ctx: Optional[Any] = ...): ...
def can_assign(self): ...

cc @rowillia who originally added them in #722

Metadata

Metadata

Assignees

No one assigned

    Labels

    stubs: incompleteAnnotations or sub-modules missing from an existing package or module

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions