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

Fixup typing #136

Merged
merged 2 commits into from
Aug 5, 2024
Merged

Fixup typing #136

merged 2 commits into from
Aug 5, 2024

Conversation

esc
Copy link
Member

@esc esc commented Jul 23, 2024

Fixup typing leftovers from #135

@@ -705,16 +706,23 @@ def rlookup(self, region_block: RegionBlock, item: Any) -> Any:
else:
raise KeyError(f"Item {item} not found in subregion or parent")

def codegen(self, block: Any) -> list[ast.AST]:
def codegen(self, block: Any) -> MutableSequence[ast.AST]:
Copy link
Member

Choose a reason for hiding this comment

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

Instead of casting result of codegen(), does it always return list[ast.stmt]?

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 may also generate a list with ast.stmt and ast.expr mixed. I.e. a list of ast.AST nodes. But list isn't covariant and since both ast.expr and ast.stmt are subclasses of ast.AST we need to use MutableSequence. NB: I also tried using Sequence but that fails to type the list.append correctly.

@esc esc merged commit 617261d into numba:main Aug 5, 2024
2 checks passed
@esc esc deleted the fixup_typing branch August 5, 2024 15:34
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.

2 participants