in `_check_toc_entries`, `sections` is assumed to be a dict but a string was passed
See original GitHub issueDescribe the bug
Unfortunately this is in the middle of a repo I’m changing a lot and I can’t push the changes that cause this up yet, sorry about that. Below is the info I best have and I hope it’s sufficient to understand the issue, if not I’ll try to clean up my example so it’s reproducible, but perhaps this is enough to point in the right direction…
Using j-book 0.9.1 on a Mac (python 3.8), with the following _toc.yml
file:
# Table of contents
# Learn more at https://jupyterbook.org/customize/toc.html
# First entry here is the website/book's landing page.
- file: overview
# The rest is structured in *parts* that then have chapters/sections.
- part: Overview
chapters:
- file: schedule
- part: Syllabus
chapters:
file: syllabus
- part: Homework Assignments
numbered: true
chapters:
file: Hw/hw01-background.md
- part: Lecture Notes
chapters:
- file: Notes/01/index
when running jupyter-book build .
I get this error:
Extension error:
Handler <function add_toc_to_sphinx at 0x7fa5bf83d5f0> for event 'config-inited' threw an exception (exception: 'str' object has no attribute 'keys')
Traceback (most recent call last):
File "/Users/fperez/local/conda/lib/python3.7/site-packages/sphinx/events.py", line 110, in emit
results.append(listener.handler(self.app, *args))
File "/Users/fperez/.local/lib/python3.7/site-packages/jupyter_book/toc.py", line 175, in add_toc_to_sphinx
_check_toc_entries([toc])
File "/Users/fperez/.local/lib/python3.7/site-packages/jupyter_book/toc.py", line 376, in _check_toc_entries
_check_toc_entries(section[section_kind])
File "/Users/fperez/.local/lib/python3.7/site-packages/jupyter_book/toc.py", line 376, in _check_toc_entries
_check_toc_entries(section[section_kind])
File "/Users/fperez/.local/lib/python3.7/site-packages/jupyter_book/toc.py", line 356, in _check_toc_entries
for key in section.keys():
AttributeError: 'str' object has no attribute 'keys'
This is the file layout of that repo, in case it helps:
drwxr-xr-x 4 fperez 128 Jan 18 11:24 Hw/
drwxr-xr-x 3 fperez 96 Jan 16 14:26 Notes/
-rw-r--r-- 1 fperez 212 Jan 15 10:47 README.md
drwxr-xr-x 5 fperez 160 Jan 17 15:57 _build/
-rw-r--r-- 1 fperez 770 Jan 18 07:50 _config.yml
-rw-r--r-- 1 fperez 475 Jan 18 11:25 _toc.yml
-rw-r--r-- 1 fperez 9854 Jan 17 15:50 logo.png
-rw-r--r-- 1 fperez 7368 Jan 18 11:08 overview.md
-rw-r--r-- 1 fperez 12058 Jan 17 15:33 schedule.md
-rw-r--r-- 1 fperez 10983 Jan 16 16:15 syllabus.md
Again, sorry for the partial report!! LMK if it’s not enough and I’ll work on a cleaner one 😃
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
python dictionary passed as an input to a function acts like ...
In the former case, it's assuming d can somehow be converted to a dict (e.g. an iterable of (key, value) pairs), while the...
Read more >Data Structures (Part II): Dictionaries
Python's dictionary allows you to store key-value pairs, and then pass the dictionary a key to quickly retrieve its corresponding value. Specifically, you ......
Read more >Dictionaries in Python
In this Python dictionaries tutorial, you'll cover the basic characteristics and learn how to access and manage dictionary data. Once you have finished...
Read more >3.4.4. Dictionaries — python_for_ss 0.1.1 documentation
Thus, this dictionary relates strings to lists of strings (Pythonistas say it maps strings to lists of strings). The strings before the colons...
Read more >Using dictionaries to store data as key-value pairs
The dictionary stores objects as key-value pairs and can be used to represent complex real-world data.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yup! The list/dict confusion was actually a yaml mistake of mine, due to being quite the yaml newbie… I didn’t actually realize this defined different yaml data structures, and so I was pretty confused by the error msg.
So my bad on that front, but the jbook validation could probably assist anyone who is similarly not very adept at spotting these yaml nuances.
Thanks a lot for the quick response!
I’m gonna close this one since I think we’ve got it figured out, and I have opened up https://github.com/executablebooks/jupyter-book/issues/1200 to track improving the error messages that are associated with these YAML config missteps.