Skip to content

Add Starred #240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Add Starred #240

wants to merge 1 commit into from

Conversation

amaydixit11
Copy link

Add Starred operator class for representing variable-length arguments

Pull Request description

This PR implements the Starred class to represent starred unpacking expressions in Python (e.g., *args, *items). This feature enables proper AST representation of variable-length arguments in function definitions and calls, as well as sequence unpacking operations.

Resolves: #203

How to test these changes

  • Run the tests with pytest libs/astx/tests/test_operators.py::test_starred*
  • Create a simple script that uses the Starred operator:
    from astx.base import Identifier
    from astx.operators import Starred
    from astx.variables import Variable
    
    # Example with variable
    args_var = Variable(name="args")
    starred_args = Starred(value=args_var)
    print(starred_args)  # Should output: Starred[*](args)
    
    # Example with identifier
    ident = Identifier(name="items")
    starred_items = Starred(value=ident)
    print(starred_items)  # Should output: Starred[*](items)

Pull Request checklists

This PR is a:

  • bug-fix
  • new feature
  • maintenance

About this PR:

  • it includes tests.
  • the tests are executed on CI.
  • the tests generate log file(s) (path).
  • pre-commit hooks were executed locally.
  • this PR requires a project documentation update.

Author's checklist:

  • I have reviewed the changes and it contains no misspelling.
  • The code is well commented, especially in the parts that contain more
    complexity.
  • New and old tests passed locally.

Additional information

ASCII representation of the Starred node:

Starred[*]
   |
   +-- value: Variable or other DataType

The implementation follows the established patterns in the codebase:

  • Uses proper typing annotations
  • Includes thorough testing
  • Maintains compatibility with existing AST nodes

This node is essential for representing Python's variable-length argument syntax and unpacking operations in function calls, function definitions, and sequence operations.

@xmnlab
Copy link
Contributor

xmnlab commented Apr 6, 2025

@amaydixit11 please fix the issues raised in the CI

Copy link

This pull request has been marked as stale because it has been
inactive for more than 5 days. Please update this pull request
or it will be automatically closed in 5 days.

@github-actions github-actions bot added the Stale label Apr 11, 2025
@xmnlab
Copy link
Contributor

xmnlab commented Apr 13, 2025

I am closing this PR because it was labeled as staled.
thanks @amaydixit11 , feel free to reopen it if you want to work on that again.

@xmnlab xmnlab closed this Apr 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

**Starred**: Represents starred unpacking (e.g., *args). Vital for variable-length arguments.
2 participants