Skip to content

AST Parsed Decorator: col_offset Value for Decorator is Function Position +1. #125778

@horw

Description

@horw

Bug report

Bug description:

import ast

code = """
@lala
def some_function():
    pass
"""

parsed_code = ast.parse(code)

fn = parsed_code.body[0]
print(fn.name, fn.col_offset)
dc = fn.decorator_list[0]
print(dc.id, dc.col_offset)

Output:

some_function 0
lala 1

CPython versions tested on:

3.11

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions