Skip to content

jinja2.exceptions.UndefinedError: 'None' has no attribute 'py_include_statement' #13

@rafalkrupinski

Description

@rafalkrupinski

Hi,
I'm trying to parse JSON Schema for OpenAPI 3 specification, and I'm getting a most cryptic error coming somewhere from jinja or a template.

Any hints on what could cause the problem?

  File "/Users/matte/Documents/Projects/lapis/src/lapis/__main__.py", line 9, in main
    generator.Generate(yaml.safe_load(fp), 'Example', 'example', 'example')

  File "/Users/matte/Library/Caches/pypoetry/virtualenvs/lapis-4Aax896p-py3.10/lib/python3.10/site-packages/jsonschemacodegen/python.py", line 51, in Generate
    return generator.render_template(template_name="file.py.jinja2", output_name="{}.py".format(filename_base), resolver=self.resolver, **args)

  File "/Users/matte/Library/Caches/pypoetry/virtualenvs/lapis-4Aax896p-py3.10/lib/python3.10/site-packages/jacobsjinjatoo/templator.py", line 92, in render_template
    rendered = template.render(kwargs)

  File "/Users/matte/Library/Caches/pypoetry/virtualenvs/lapis-4Aax896p-py3.10/lib/python3.10/site-packages/jinja2/environment.py", line 1304, in render
    self.environment.handle_exception()

  File "/Users/matte/Library/Caches/pypoetry/virtualenvs/lapis-4Aax896p-py3.10/lib/python3.10/site-packages/jinja2/environment.py", line 925, in handle_exception
    raise rewrite_traceback_stack(source=source)

  File "/Users/matte/Library/Caches/pypoetry/virtualenvs/lapis-4Aax896p-py3.10/lib/python3.10/site-packages/jsonschemacodegen/templates/python/file.py.jinja2", line 8, in <module>
    {{importer.GetImports(resolver, schema, includes)}}

  File "/Users/matte/Library/Caches/pypoetry/virtualenvs/lapis-4Aax896p-py3.10/lib/python3.10/site-packages/jinja2/runtime.py", line 828, in _invoke
    rv = self._func(*arguments)

  File "/Users/matte/Library/Caches/pypoetry/virtualenvs/lapis-4Aax896p-py3.10/lib/python3.10/site-packages/jsonschemacodegen/templates/python/import.py.jinja2", line 67, in <module>
    {%-            do includes.append(resolver.py_include_statement(prop['$ref']))-%}

  File "/Users/matte/Library/Caches/pypoetry/virtualenvs/lapis-4Aax896p-py3.10/lib/python3.10/site-packages/jinja2/utils.py", line 84, in from_obj
    if hasattr(obj, "jinja_pass_arg"):

jinja2.exceptions.UndefinedError: 'None' has no attribute 'py_include_statement'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions