question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Section nav error: TypeError: unsupported operand type(s) for +: 'int' and 'str'

See original GitHub issue

I’ve found a bug and checked that …

  • [ x] … the problem doesn’t occur with the default MkDocs template
  • [x ] … the problem is not in any of my customizations (CSS, JS, template)
  • [ x] … the documentation does not mention anything about my problem
  • [ x] … there are no open or closed issues that are related to my problem

Description

I get the following error when activating section based navigation with mkdocs-material-6.1.4+insiders-1.9.0 in a minimal website.

ERROR   -  Exception in callback <bound method LiveReloadHandler.poll_tasks of <class 'livereload.handlers.LiveReloadHandler'>>
Traceback (most recent call last):
  File "/usr/local/Caskroom/miniconda/base/envs/rapids202008/lib/python3.7/site-packages/tornado/ioloop.py", line 907, in _run
    return self.callback()
  File "/usr/local/Caskroom/miniconda/base/envs/rapids202008/lib/python3.7/site-packages/livereload/handlers.py", line 69, in poll_tasks
    filepath, delay = cls.watcher.examine()
  File "/usr/local/Caskroom/miniconda/base/envs/rapids202008/lib/python3.7/site-packages/livereload/watcher.py", line 119, in examine
    func()
  File "/usr/local/Caskroom/miniconda/base/envs/rapids202008/lib/python3.7/site-packages/mkdocs/commands/serve.py", line 136, in builder
    build(config, live_server=live_server, dirty=dirty)
  File "/usr/local/Caskroom/miniconda/base/envs/rapids202008/lib/python3.7/site-packages/mkdocs/commands/build.py", line 285, in build
    _build_theme_template(template, env, files, config, nav)
  File "/usr/local/Caskroom/miniconda/base/envs/rapids202008/lib/python3.7/site-packages/mkdocs/commands/build.py", line 108, in _build_theme_template
    output = _build_template(template_name, template, files, config, nav)
  File "/usr/local/Caskroom/miniconda/base/envs/rapids202008/lib/python3.7/site-packages/mkdocs/commands/build.py", line 87, in _build_template
    output = template.render(context)
  File "/usr/local/Caskroom/miniconda/base/envs/rapids202008/lib/python3.7/site-packages/jinja2/asyncsupport.py", line 76, in render
    return original_render(self, *args, **kwargs)
  File "/usr/local/Caskroom/miniconda/base/envs/rapids202008/lib/python3.7/site-packages/jinja2/environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/local/Caskroom/miniconda/base/envs/rapids202008/lib/python3.7/site-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/Caskroom/miniconda/base/envs/rapids202008/lib/python3.7/site-packages/jinja2/_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/Caskroom/miniconda/base/envs/rapids202008/lib/python3.7/site-packages/material/404.html", line 4, in top-level template code
    {% extends "main.html" %}
  File "/usr/local/Caskroom/miniconda/base/envs/rapids202008/lib/python3.7/site-packages/jinja2/environment.py", line 1005, in render
    return concat(self.root_render_func(self.new_context(vars)))
  File "/usr/local/Caskroom/miniconda/base/envs/rapids202008/lib/python3.7/site-packages/material/404.html", line 14, in root
  File "/usr/local/Caskroom/miniconda/base/envs/rapids202008/lib/python3.7/site-packages/material/main.html", line 14, in root
  File "/usr/local/Caskroom/miniconda/base/envs/rapids202008/lib/python3.7/site-packages/material/base.html", line 126, in root
    <main class="md-main" data-md-component="main">
  File "/usr/local/Caskroom/miniconda/base/envs/rapids202008/lib/python3.7/site-packages/material/base.html", line 360, in block_site_nav
  File "/usr/local/Caskroom/miniconda/base/envs/rapids202008/lib/python3.7/site-packages/material/partials/nav.html", line 59, in root
  File "/usr/local/Caskroom/miniconda/base/envs/rapids202008/lib/python3.7/site-packages/material/partials/nav-item.html", line 38, in root
    </nav>
TypeError: unsupported operand type(s) for +: 'int' and 'str'

Expected behavior

Load the website without errors and with section navigation

Actual behavior

The website is not rendered

Steps to reproduce the bug

  1. Install mkdocs-material-6.1.4+insiders-1.9.0
  2. Setup the mkdocs.yml described below
  3. Create a test file under /docs/test.md with this line # My Test
  4. mkdocs serve

Package versions

  • Python: 3.7.3 python --version
  • MkDocs: 1.1.2 mkdocs --version
  • Material: Version: 6.1.4+insiders.1.9.0 pip show mkdocs-material | grep -E ^Version

Project configuration

site_name: Test
theme:
  name: material
  features:
    - navigation.sections
nav:
  - Others:
    - Team: test.md

System information

  • OS: MacOS 10.15.7

  • Browser: Firefox 82.0.2

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
binwiederhiercommented, Dec 7, 2021

For the Googlers, I ran into the same issue here: https://github.com/binwiederhier/ntfy/actions/runs/1550547757 and fixed it with an explicit jinja2 dependency, here: https://github.com/binwiederhier/ntfy/commit/ab3cc47e272aa0d21f8b3fd134265611916b6416#diff-4d7c51b1efe9043e44439a949dfd92e5827321b34082903477fd04876edb7552R4

Thanks @liuhualh for the hint and thanks @squidfunk for a freaking awesome piece of software (which has docs here: https://ntfy.sh/docs).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unsupported operand type(s) for +: 'int' and 'str' - Stack Overflow
You're trying to concatenate a string and an integer, which is incorrect. Change print(numlist.pop(2)+" has been removed") to any of these:.
Read more >
Python TypeError: unsupported operand type(s) for -: 'str' and ...
The “TypeError: unsupported operand type(s) for -: 'str' and 'int'” error is raised when you try to subtract a string from an integer....
Read more >
Unsupported operand type s for int and str | Edureka Community
You seem to be trying to train a string and an integer, which is incorrect. Alter the print(numlist.pop(2)+" has been removed") to any...
Read more >
Unsupported operand type(s) for +: 'int' and 'str' | Neeraj Sharma
To the point and easy explanation why this " TypeError : unsupported operand type ( s) for +: ' int' and 'str '"...
Read more >
TypeError: unsupported operand type(s) for +: int and str
The Python "TypeError: unsupported operand type(s) for +: 'int' and 'str'" occurs when we try to use the addition (+) operator with an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found