Skip to content

Support for Multi-line Code Snippets with #@ Marker #2566

Open
@PeterHamfelt

Description

@PeterHamfelt

Steps to reproduce

  1. Write a multi-line code snippet (e.g., a Keras Sequential model definition) and place the #@ marker at the end of the line.
  2. Try splitting the code across multiple lines while keeping the #@ marker.
  3. Run the checker that leverages the #@ marker to see how nodes are created.

Current behavior

The code checker creates new nodes for each line when the #@ marker is used in multi-line code snippets, resulting in separate nodes rather than treating the code block as one unit. This reduces the clarity of scenarios and makes it challenging to handle more complex, multi-line code.

model = tf.keras.Sequential(layers=[
    tf.keras.layers.Dense(units=64, activation='relu'),
    tf.keras.layers.Dense(units=10)
])  #@

Additionally, having everything on a single line makes the code harder to read and maintain. For example, writing it all in one line like below is less readable and too long:

model = tf.keras.Sequential(layers=[tf.keras.layers.Dense(units=64, activation='relu'), tf.keras.layers.Dense(units=10)]) #@

Expected behavior

The code checker should treat multi-line code snippets marked with #@ as a single unit, allowing for improved readability and easier handling of more complex scenarios.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Enhancement ✨Improvement to a componentNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions