Skip to content

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

Open
andrewwhitecdw wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
andrewwhitecdw:andrewwhitecdw/fix/deprecated-ast-constants
Open

fix: replace deprecated ast.* literal types with ast.Constant#567
andrewwhitecdw wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
andrewwhitecdw:andrewwhitecdw/fix/deprecated-ast-constants

Conversation

@andrewwhitecdw

Copy link
Copy Markdown

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>
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.

1 participant