Skip to content

fix: use ast.Constant.value in docs conf parse_version - #439

Merged
Erotemic merged 1 commit into
pyutils:mainfrom
Sanjays2402:fix/docs-conf-ast-constant-py314
Sep 15, 2026
Merged

Erotemic merged 1 commit into
pyutils:mainfrom
Sanjays2402:fix/docs-conf-ast-constant-py314

Conversation

@Sanjays2402

Copy link
Copy Markdown
Contributor

Closes #429

ast.Constant.s was removed in Python 3.14, so parse_version() in docs/source/conf.py raised AttributeError: 'Constant' object has no attribute 's' while statically reading __version__, and Sphinx aborted with a ConfigError. Reading node.value.value instead (the canonical field since Python 3.8) fixes the build.

Added tests/test_docs_conf.py, which extracts parse_version from conf.py without importing sphinx; it fails with the reported AttributeError before this change and passes after.

Sphinx docs failed to build on Python 3.14 with
"AttributeError: 'Constant' object has no attribute 's'".

The deprecated ast.Constant.s alias was removed in Python 3.14, so
parse_version() in docs/source/conf.py raised while statically reading
__version__ and Sphinx aborted with a ConfigError.

Read node.value.value instead, which has been the canonical field since
Python 3.8. Added tests/test_docs_conf.py, which extracts parse_version
from conf.py (without importing sphinx) and asserts it parses a version
string; it fails with the reported AttributeError before this change.
@Erotemic
Erotemic merged commit d0878e7 into pyutils:main Sep 15, 2026
@Erotemic

Copy link
Copy Markdown
Member

Sorry for taking so long to click merge on a simple fix. These boilerplate files are generated via my xcookie package, so the real fix is in xcookie itself (and I think it already landed), but this is fine for a stop gap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docs fail to build on Python 3.14 (ast.Constant.s no longer supported)

2 participants