Skip to content

feat(test): Failure test case for mypyc dictionary subclass views #19076

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

BobTheBuidler
Copy link

@BobTheBuidler BobTheBuidler commented May 12, 2025

I've created a failing test case for a mypyc bug with dict views as seen here: https://github.com/BobTheBuidler/checksum_dict/actions/runs/14843222374/job/41670896987

I added some new (working) test cases:

  • dict
    • keys
    • values
    • items
  • dict subclass
    • keys
    • values
    • items

and the failure cases:

  • dict subclass with 2 bases
    • keys
    • values
    • items

@BobTheBuidler BobTheBuidler changed the title feat(test): test mypyc dict views feat(test): Failure test case for mypyc dictionary subclass views May 12, 2025
@BobTheBuidler
Copy link
Author

@JukkaL Would you happen to know what I need to change so the tests are able to find the DefaultDict object in the typing module? Or is there someone better to ask about this?

@BobTheBuidler
Copy link
Author

Fascinating, I've managed to make it work using a type: ignore comment, and now we have our successful (wut?) failure case!

@BobTheBuidler BobTheBuidler marked this pull request as ready for review May 14, 2025 03:39
@JukkaL
Copy link
Collaborator

JukkaL commented Jun 7, 2025

It's unclear what's the best approach here. @mypyc_attr(native_class=False) could act as a workaround (with some performance cost). We could also declare this as an unsupported use case, and generate an error with a note suggesting the @mypyc_attr workaround, in case it works.

@BobTheBuidler
Copy link
Author

Hmm. That could work but I'd first like to try a bit to resolve it, I just need some help to know where I should look for the relevant code. Is there not a strightforward way to tell mypyc to only use the dict.keys c function when obj.keys actually resolves to dict.keys, and fallback to python's name resolution when it does not?

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