You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BodyView.blocks() and .attributes() are annotated as List[NodeView] #328
blocks() yields only BlockView, attributes() only AttributeView, and BlockView.body is always a BodyView. Callers under mypy --strict
therefore cannot reach block_type, labels, name_labels or AttributeView.name without an isinstance narrowing or a cast, even though
the runtime type is never anything else. DocumentView and BlockView widen
the same way in their delegating methods.
Narrowing the annotations to List["BlockView"] and List["AttributeView"]
would make the query API usable from typed code as written. This is
annotation-only; no runtime behaviour changes, and the view classes stay
imported inside the method bodies, since that import cycle is real.
(Noticed while porting a downstream Terraform block reader onto hcl2.query —
the views are otherwise a very good fit, they replaced about fifty lines of
hand-rolled rule-tree walking.)
The investigation behind this report was produced with AI assistance, working on my behalf. Every reproduction, version comparison and measurement cited was executed rather than inferred; I reviewed it before filing.
This issue, and the investigation behind it, were produced by an AI assistant (Claude) working on behalf of the author. Please review with that provenance in mind.
Activity
test: pin the import order the annotation cycle depends on (amplify-e…