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

Allow schema generation with loops #19

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions jinja2schema/visitors/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ def wrapped_func(ast, ctx, macroses=None, config=default_config):
return wrapped_func
return decorator


def visit_expr(ast, ctx, macroses=None, config=default_config):
"""Returns a structure of ``ast``.

Expand Down Expand Up @@ -398,7 +397,9 @@ def visit_call(ast, ctx, macroses=None, config=default_config):
else:
raise InvalidExpression(ast, '"{0}" call is not supported'.format(ast.node.name))
elif isinstance(ast.node, nodes.Getattr):
if ast.node.attr in ('keys', 'iterkeys', 'values', 'itervalues'):
if ast.node.node.name in ('loop'):
return Unknown(), Unknown()
elif ast.node.attr in ('keys', 'iterkeys', 'values', 'itervalues'):
ctx.meet(List(Unknown()), ast)
rtype, struct = visit_expr(
ast.node.node, Context(
Expand Down