Skip to content

fix(python): allow type predicates in return annotations#672

Open
hechibing wants to merge 3 commits intobiomejs:mainfrom
hechibing:fix/python-type-predicate-424
Open

fix(python): allow type predicates in return annotations#672
hechibing wants to merge 3 commits intobiomejs:mainfrom
hechibing:fix/python-type-predicate-424

Conversation

@hechibing
Copy link

Fixes #424

Changes:

  • Add a Python snippet parse context for return type annotations, so type predicates can compare return types against snippets like List
  • Add a regression test for matching a type predicate on a Python return annotation

Verification:

  • (Not run locally) cargo test -p marzano-core python_match_type_predicate_on_return_annotation

This lets snippets like List compile patterns for 	ype wrapper nodes, so $type <: List` works in Python return annotations.
@hechibing
Copy link
Author

Verification (Windows):

  • cargo test -p marzano-core --no-default-features --features grit-parser,language-parsers,non_wasm python_match_type_predicate_on_return_annotation

Notes:

  • Fix required keeping wrapper nodes (like Python ype in return annotations) when compiling snippets, so List can match a ype node.

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.

Can't match type predicates in Python

2 participants