the documented order of parameters in "arguments" node is different than actual order in CPython

Issue #13 resolved
Mateusz Bysiek created an issue

The order should be as described at https://github.com/python/cpython/blob/master/Parser/Python.asdl#L114:

arguments = (arg* args, arg* posonlyargs, arg? vararg, arg* kwonlyargs,
             expr* kw_defaults, arg? kwarg, expr* defaults)

But documentation at https://greentreesnakes.readthedocs.io/en/latest/nodes.html#arguments says:

arguments(args, vararg, kwonlyargs, kwarg, defaults, kw_defaults)

Interestingly, the example given for the arg() node follows the actual argument order. This doesn't matter in the example since it uses kwargs, but if one uses args to initialize arguments()…

I’ll try to submit a PR in a minute.

Comments (4)

  1. Mateusz Bysiek reporter

    Also I just noticed that there is a new posonlyargs parameter in master branch, so for 3.8 onwards additional change might be needed.

    But in any case, for now, for 3.4-3.7 (and in all likelihood, also in 3.0-3.3), the order was also different than in the docs.

    3.7 https://github.com/python/cpython/blob/3.7/Parser/Python.asdl#L118:

    arguments = (arg* args, arg? vararg, arg* kwonlyargs, expr* kw_defaults,
                 arg? kwarg, expr* defaults)
    

    3.6 https://github.com/python/cpython/blob/3.6/Parser/Python.asdl#L118:

    arguments = (arg* args, arg? vararg, arg* kwonlyargs, expr* kw_defaults,
                 arg? kwarg, expr* defaults)
    

    3.5 https://github.com/python/cpython/blob/3.5/Parser/Python.asdl#L109:

    arguments = (arg* args, arg? vararg, arg* kwonlyargs, expr* kw_defaults,
                 arg? kwarg, expr* defaults)
    

    3.4 https://github.com/python/cpython/blob/3.4/Parser/Python.asdl#L106:

    arguments = (arg* args, arg? vararg, arg* kwonlyargs, expr* kw_defaults,
                 arg? kwarg, expr* defaults)
    
  2. Mateusz Bysiek reporter

    I’ve submitted pull request #11 to fix docs as of Python 3.7, please take a look.

    For Python 3.8 there will be also many other additional fixes needed anyway, e.g. type comments etc, so I’m keeping away from those for now.

  3. Log in to comment