[issue39981] Default values for AST Nodes

2020-07-09 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
pull_requests: +20566
pull_request: https://github.com/python/cpython/pull/21417

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39981] Default values for AST Nodes

2020-03-16 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
keywords: +patch
pull_requests: +18380
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/19031

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39981] Default values for AST Nodes

2020-03-16 Thread Batuhan Taskaya


New submission from Batuhan Taskaya :

For omitting some defaults, @serhiy.storchaka already added support to 
initialize some ast nodes with some default values (optional fields). An 
example;
>>> ast.Constant().kind is None
True

This isn't exactly a default value, but some kind of class attribute. I think 
we can push this one step further and initialize all kinds of default values 
(both optionals and sequences). An example;
>>> func = ast.FunctionDef("easy_func", ast.arguments(), body=[ast.Pass()])
>>> func = ast.fix_missing_locations(func)
>>> exec(compile(ast.Module(body=[func]), "", "exec"))
>>> easy_func()

compared to this (other way around, compiler gives errors so does most of the 
ast based tool, including ast.unparser)
>>> func = ast.FunctionDef("easy_func", ast.arguments(posonlyargs=[], args=[], 
>>> kwonlyargs=[], kw_defaults=[], defaults=[]), decorator_list=[], 
>>> body=[ast.Pass()])
>>> func = ast.fix_missing_locations(func)
>>> exec(compile(ast.Module(body=[func], type_ignores=[]), "", "exec"))
>>> easy_func()

--
components: Library (Lib)
messages: 364355
nosy: BTaskaya, benjamin.peterson, pablogsal, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Default values for AST Nodes
type: enhancement
versions: Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com