canonical / canonical/pydantic-kitbash

Examples are required to be strings

Open
#11 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
3
Forks
2
Avg merge
1d 5h
Merged PRs (30d)
9

Description

Right now each example is required to be a string, even if the type isn't necessarily a string.

Given this input:

```python
build_on: list[str] | str = pydantic.Field(
min_length=1,
examples=[
"amd64",
["arm64", "riscv64"]
]
)
```

I would expect it to work properly. However, instead I get this exception:

```
Exception occurred:
File "/home/lengau/Work/Code/craft-application/.venv/lib/python3.12/site-packages/yaml/reader.py", line 178, in update_raw
data = self.stream.read(size)
^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'read'
The full traceback has been saved in /tmp/sphinx-err-ua2zgx1a.log, if you want to report the issue to the developers.
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the shown Pydantic Field example and inspect the Sphinx extension's handling of the field's examples before the yaml.reader failure in the traceback. Done means examples containing both strings and lists are accepted without the reported AttributeError and the YAML reference documentation is generated successfully.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.