Skip to content

Inject std.getitem on parsing ast.Subscript#292

Merged
liamhuber merged 1 commit into
parser-qolfrom
item-access
Jul 17, 2026
Merged

Inject std.getitem on parsing ast.Subscript#292
liamhuber merged 1 commit into
parser-qolfrom
item-access

Conversation

@liamhuber

Copy link
Copy Markdown
Member

I.e. to parse things like new_symbol = old_symbol[other_symbol]["constant"]. Rides a lot of the same infrastructure has attribute access, so this was pulled up to a generic "chain" parser, and arbitrary attribute/item access chains work by injecting their respective stdlib nodes.

Required a bit of an extra guard on the while-node to protect against looped keys:

def wf(d: dict, seed: int):
    x = std.identity(seed)
    while library.my_condition(x, d[x]):
        x = library.loop_inc(x)
    return x

I.e. to parse things like `new_symbol = old_symbol[other_symbol]["constant"]`. Rides a lot of the same infrastructure has attribute access, so this was pulled up to a generic "chain" parser, and arbitrary attribute/item access chains work by injecting their respective stdlib nodes.

Required a bit of an extra guard on the while-node to protect against looped keys:

def wf(d: dict, seed: int):
    x = std.identity(seed)
    while library.my_condition(x, d[x]):
        x = library.loop_inc(x)
    return x

Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Liam Huber <liamhuber@greyhavensolutions.com>
@github-actions

Copy link
Copy Markdown

Binder 👈 Launch a binder notebook on branch pyiron/flowrep/item-access

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.97%. Comparing base (8db644e) to head (797f142).

Additional details and impacted files
@@             Coverage Diff             @@
##           parser-qol     #292   +/-   ##
===========================================
  Coverage       99.97%   99.97%           
===========================================
  Files              41       43    +2     
  Lines            3433     3502   +69     
===========================================
+ Hits             3432     3501   +69     
  Misses              1        1           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@liamhuber liamhuber mentioned this pull request Jul 17, 2026
7 tasks
@liamhuber
liamhuber merged commit 67d0176 into parser-qol Jul 17, 2026
22 checks passed
@liamhuber
liamhuber deleted the item-access branch July 17, 2026 04:54
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.

1 participant