-
Notifications
You must be signed in to change notification settings - Fork 196
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
Walrus operator's left hand side now has STORE expression context #433
Conversation
Codecov Report
@@ Coverage Diff @@
## master #433 +/- ##
==========================================
- Coverage 94.32% 94.31% -0.01%
==========================================
Files 232 232
Lines 22641 22657 +16
==========================================
+ Hits 21355 21368 +13
- Misses 1286 1289 +3
Continue to review full report at Codecov.
|
if x := y: | ||
pass | ||
""" | ||
wrapper = MetadataWrapper(parse_module(dedent(code))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version can be decoupled; if you want, this will let the test run everywhere:
parse_module(
dedent(code),
config=cst.PartialParserConfig(python_version="3.8"),
)
@@ -1609,6 +1610,27 @@ def test_no_out_of_order_references_in_global_scope(self) -> None: | |||
), | |||
) | |||
|
|||
def test_walrus_accesses(self) -> None: | |||
if sys.version_info < (3, 8): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is not as easy, I'd have to plumb the parser config through some helper functions, so I thought it's fine to keep it as is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change is pretty good.
Summary
This PR makes scope provider assign a
STORE
expression context to the left hand side of a walrus operator. So, in anx := y
expression,x
should haveExpressionContext.STORE
as its expression context metadata.Test Plan
Added unit tests.