Skip to content

Add dict comprehension Support #217

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 4 commits into from

Conversation

Zehen-249
Copy link
Contributor

Pull Request description

Add DictComprehension class to support Dictionary comprehension

Solve #198

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

screenshot that helps to show the changes proposed

image
image
image

Copy and paste this template for your review's note:

## Reviewer's Checklist

- [ ] I managed to reproduce the problem locally from the `main` branch
- [ ] I managed to test the new changes locally
- [ ] I confirm that the issues mentioned were fixed/resolved .

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@xmnlab
Copy link
Contributor

xmnlab commented Mar 18, 2025

hi @Zehen-249 ! thanks for working on that. ensure you are running the pre-commit locally, and ping me here when all the tests on ci pass, please.

@Zehen-249 Zehen-249 force-pushed the Add_Dict_comprehension branch from f04be0d to ca55364 Compare March 18, 2025 10:34
@Zehen-249
Copy link
Contributor Author

Hey Ivan
image
I am failing his check in the modifiers file I haven't change anything in Modifiers.py

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 Mar 24, 2025
@xmnlab
Copy link
Contributor

xmnlab commented Mar 24, 2025

@Zehen-249 , maybe the issue was just locally .. on ci it worked.

@@ -1,5 +1,10 @@
"""Test Python Transpiler."""

# for running tests from local astx module
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove these comments.

btw, if you install with poetry install, you shouldn't need any of these hacks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay sure I will do it. I actually did used poetry.


def __init__(
self,
key: Identifier,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

key and value probably should be Expr instead of Indentifier ... but maybe we need to discuss a bit other part of this class.

let's consider this example:

>>> ast.dump(ast.parse("{'y': x*x for x in my_list}"))
"Module(body=[Expr(value=DictComp(key=Constant(value='y'), value=BinOp(left=Name(id='x', ctx=Load()), op=Mult(), right=Name(id='x', ctx=Load())), generators=[comprehension(target=Name(id='x', ctx=Store()), iter=Name(id='my_list', ctx=Load()), ifs=[], is_async=0)]))], type_ignores=[])"

se it seems we will also need to add ifs and the comprehension class as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will work on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually did considered Expr for these variables but during pre-commit checks I was failing some checks bcoz, Expr did not have value attribute. But my tests was doing fine coz I had initialized key value as identifiers in the object creation.

@Zehen-249
Copy link
Contributor Author

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.

Could you pls remove this stale

@github-actions github-actions bot removed the Stale label Mar 25, 2025
@xmnlab
Copy link
Contributor

xmnlab commented Mar 25, 2025

@Zehen-249 , I just added support for the Comprehension class, please update your PR to use that: #225

@Zehen-249
Copy link
Contributor Author

hey @xmnlab I have created a new PR for this issue. Should CLOSE this PR.

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

Successfully merging this pull request may close these issues.

2 participants