Skip to content
Latchkey

flit "Missing version or docstring" in CI

flit derives the distribution version from your module's __version__ and the summary from its top-level docstring. If either is missing and not declared dynamic, flit refuses to build because it cannot fill required metadata.

What this error means

The flit build fails with "Missing version or docstring" (or a message that version/description are required) pointing at your package's __init__.py.

flit
Missing version or docstring in module mypkg
# flit reads __version__ and the module docstring for metadata

Common causes

No __version__ in the module

flit looks for __version__ = "..." at module level. Without it, there is no version to publish.

No module docstring for the summary

flit uses the first line of the module docstring as the package summary; an undocumented module leaves description empty.

How to fix it

Add __version__ and a docstring

  1. Add a top-level docstring to your package module.
  2. Define __version__ at module scope.
  3. Re-run the flit build.
src/mypkg/__init__.py
"""A small example package."""

__version__ = "0.3.1"

Declare metadata as dynamic

If you provide version and description elsewhere, mark them dynamic so flit does not require them in the module.

pyproject.toml
[project]
name = "mypkg"
dynamic = ["version", "description"]

How to prevent it

  • Keep __version__ and a module docstring in your package entry module.
  • Use dynamic consistently when metadata lives elsewhere.
  • Build with flit in CI to catch missing metadata.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →