sphinx-doc / sphinx-doc/sphinx

TypeError(f'{name!r} is a field but has no type annotation')

Open
#14,656 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:bug
Dominant language
Python
Stars
8k
Forks
2.6k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
* Sphinx version:   8.2.0
* Docutils version: 0.23
* Jinja2 version:   3.1.5
* Pygments version: 2.14.0 (will shortly update to 2.20)

Traceback
=========

Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/sphinx/cmd/build.py", line 414, in build_main
    app = Sphinx(
  File "/usr/lib/python3.12/site-packages/sphinx/application.py", line 286, in __init__
    self.setup_extension(extension)
  File "/usr/lib/python3.12/site-packages/sphinx/application.py", line 490, in setup_extension
    self.registry.load_extension(self, extname)
  File "/usr/lib/python3.12/site-packages/sphinx/registry.py", line 541, in load_extension
    mod = import_module(extname)
  File "/usr/lib/python3.12/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/lib/python3.12/site-packages/sphinx/builders/epub3.py", line 16, in <module>
    from sphinx.builders import _epub_base
  File "/usr/lib/python3.12/site-packages/sphinx/builders/_epub_base.py", line 19, in <module>
    from sphinx.builders.html import StandaloneHTMLBuilder
  File "/usr/lib/python3.12/site-packages/sphinx/builders/html/__init__.py", line 43, in <module>
    from sphinx.search import js_index
  File "/usr/lib/python3.12/site-packages/sphinx/search/__init__.py", line 211, in <module>
    class WordStore:
  File "/usr/lib/python3.12/dataclasses.py", line 1185, in dataclass
    return wrap(cls)
  File "/usr/lib/python3.12/dataclasses.py", line 1176, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
  File "/usr/lib/python3.12/dataclasses.py", line 980, in _process_class
    raise TypeError(f'{name!r} is a field but has no type annotation')
TypeError: 'words' is a field but has no type annotation
How to Reproduce

docs building step of vdirsyncer:

sphinx-build -b man docs/ build/

https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=vdirsyncer-git

Environment Information
I won't use pip, only my distro's packaging.
Sphinx extensions

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with sphinx/search/init.py and the WordStore declaration named in the traceback, then reproduce with sphinx-build -b man docs/ build/ from vdirsyncer. Trace the dataclass processing that raises the error and verify that the same documentation build completes successfully after the issue is addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.