Skip to content

fix: replace deprecated ast.* literal types with ast.Constant - #567

Merged
ko3n1g merged 2 commits into
NVIDIA-NeMo:mainfrom
andrewwhitecdw:andrewwhitecdw/fix/deprecated-ast-constants
Aug 7, 2026
Merged

fix: replace deprecated ast.* literal types with ast.Constant#567
ko3n1g merged 2 commits into
NVIDIA-NeMo:mainfrom
andrewwhitecdw:andrewwhitecdw/fix/deprecated-ast-constants

Conversation

@andrewwhitecdw

Copy link
Copy Markdown
Contributor

Bug

ast.Num, ast.Str, ast.Bytes, ast.NameConstant, and ast.Ellipsis are deprecated and removed in Python 3.14. ast.Constant has been the canonical representation since Python 3.8.

Fix

Replace the deprecated type checks in nemo_run/cli/lazy.py and nemo_run/cli/cli_parser.py with ast.Constant.

Test

Added test/cli/test_ast_constants.py::TestPythonicParserLiteralSafety, which verifies PythonicParser._contains_unsafe_operations treats literal constants (int, str, bytes, True, None, Ellipsis) as safe.

Verification

uv run pytest test/cli/test_ast_constants.py -v passes. uv run --group lint ruff check ... and ruff format --check ... pass.

ast.Num, ast.Str, ast.Bytes, ast.NameConstant, and ast.Ellipsis are

deprecated and removed in Python 3.14. ast.Constant has been the canonical

representation since Python 3.8.

Adds regression tests verifying PythonicParser treats literal constants as safe.

Signed-off-by: Andrew White <andrewh@cdw.com>

Copy link
Copy Markdown
Contributor

PR #567 — LGTM
Blocking findings: None.
Non-blocking findings: None. nemo_run/cli/cli_parser.py:518-524 preserves the safety policy while using ast.Constant, and nemo_run/cli/lazy.py:833-840 preserves the __name__ == "__main__" detection. test/cli/test_ast_constants.py:28-41 covers all migrated literal categories.
Validation gaps: Python 3.14 compatibility is not exercised by the repository's current 3.10–3.12 matrix; only DCO is visible for this head.

@ko3n1g
ko3n1g enabled auto-merge (squash) August 7, 2026 11:45
@ko3n1g
ko3n1g merged commit 6e15e2d into NVIDIA-NeMo:main Aug 7, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants