Skip to content
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

Python: Add basic flow for class attributes #14706

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

RasmusWL
Copy link
Member

@RasmusWL RasmusWL commented Nov 7, 2023

No description provided.

All are for the better 🎉
@RasmusWL
Copy link
Member Author

RasmusWL commented Nov 7, 2023

FYI: Tests on this PR will fail until #14590 is merged (now merged into this PR 👍)

yoff
yoff previously approved these changes Nov 9, 2023
Copy link
Contributor

@yoff yoff left a comment

Choose a reason for hiding this comment

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

Some questions, but I think this is an improvement regardless of the answers and further improvements can be made later. You included a nice set of test to make that easier 👍

@@ -64,7 +64,7 @@ class Unsafe:
def test_value_pattern():
match SOURCE:
case Unsafe.VALUE as x:
SINK(x) #$ flow="SOURCE, l:-2 -> x" MISSING: flow="SOURCE, l:-5 -> x"
SINK(x) #$ flow="SOURCE, l:-2 -> x" flow="SOURCE, l:-5 -> x"
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice bonus :-)


set_to_source()

SINK(WithTuple2.my_tuple[0]) # $ MISSING: flow="SOURCE, l:-10 -> WithTuple2.my_tuple[0]"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this missing because we do not have post-update nodes?

Copy link
Member Author

Choose a reason for hiding this comment

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

No. It's missing because we don't have any global for the store to WithTuple2 in set_to_source, to the reference in the test_class_override function. Without that global flow (jump step), we just get flow from the class definition (that is, think it's still a nonsource).

If we inlined set_to_source, we would get flow through normal attribute-store, so that doesn't count.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've renamed the function to make this more clear

class Outer:
src = SOURCE
class Inner:
src = SOURCE
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want a test updating this value, to test the need for post-update nodes?

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't find a need for it. Happy to accept a suggestion if you feel like it 😊

@RasmusWL RasmusWL requested a review from yoff November 10, 2023 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants