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

[BUG]: annotating argument as list[some_type] raises CompileError #4214

Closed
jbrockmendel opened this issue Jun 5, 2021 · 3 comments
Closed

Comments

@jbrockmendel
Copy link
Contributor

Trying to add pure-py annotation here

-def append(self, others) -> BlockPlacement:
+def append(self, others: list[BlockPlacement]) -> BlockPlacement:

raises

pandas/_libs/internals.pyx:166:57: Compiler crash in IterationTransform
@da-woods
Copy link
Contributor

da-woods commented Jun 5, 2021

I assume this is 0.29.x you're using (although the same bug probably exists on 3.0a)?

Ultimately #3910 should help with this sort of thing (although it currently only looks at the typing module and doesn't make the built-in types subscriptable; that's probably a fairly easy change for the future though).

For the moment Cython's unlikely to use the [BlockPlacement] information, so one solution would be to omit that. Obviously you may want it for your own documentation though.

I imagine the likely outcome is that 0.29.x will end up treating this as object (but not crashing) but at some point 3.0x will recognise it correctly as list.

@jbrockmendel
Copy link
Contributor Author

I assume this is 0.29.x you're using (although the same bug probably exists on 3.0a)?

ive only tried this on 0.29.23

For the moment Cython's unlikely to use the [BlockPlacement] information, so one solution would be to omit that. Obviously you may want it for your own documentation though.

yah, this is basically cosmetic in this context

da-woods added a commit to da-woods/cython that referenced this issue Jun 6, 2021
Fixes cython#4214

This isn't a problem in Cython 3 (so only goes into 0.29.x,
although should merge into 3 cleanly I think)
@da-woods
Copy link
Contributor

da-woods commented Jun 6, 2021

FWIW this was a duplicate of #2811. It looks like that didn't get backported. I've created a PR with a minimal bit backported, but it's possible that this isn't the cleanest way to fix it.

No longer true - it's probably best to just backport the whole thing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants