Skip to content

Parsing of commented code throws 'misplaced type annotation' #708

@Flamefire

Description

@Flamefire

Steps to reproduce

  1. Try to parse e.g. tensorflow_core/python/ops/gen_resource_variable_ops.py

Alternatively the code that triggers this:

def _InitOpDefLibrary(op_list_proto_bytes): op_list = _op_def_pb2.OpList() op_list.ParseFromString(op_list_proto_bytes) _op_def_registry.register_op_list(op_list) op_def_lib = _op_def_library.OpDefLibrary() op_def_lib.add_op_list(op_list) return op_def_lib # op { # name: "AssignAddVariableOp" # input_arg { # name: "resource" # type: DT_RESOURCE # } # input_arg { # name: "value" # type_attr: "dtype" # } # attr { # name: "dtype" # type: "type" # } # is_stateful: true # } 

Current behavior

Exception thrown (SyntaxError)

Expected behavior

Exception/Error ignored (as there is none)

python -c "from astroid import __pkginfo__; print(__pkginfo__.version)" output

2.3.1

Note that this happens when parsing tensorflow e.g. for pylint, so this is a real use case, although with presumptly generated code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions