-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[easy] Enhance the protocol checker #560
Comments
Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore): Here's a short list of checks that can be implemented:
|
Hi, I'm at the Pycon canada sprints and I like to try to fix this issue. I'm thinking of following the same approach as in #845, is that a good place to start? Thanks |
Hi @craig-sh Yeah, that's a good place to start! Thanks for taking a look at it! |
I added some code to check if __bool__returns a bool. If you get a chance could you take a look at the WIP pull request and let me know if I'm on the right track? |
This commit adds multiple checks for various Python protocols E0304 (invalid-bool-returned): __bool__ did not return a bool E0305 (invalid-index-returned): __index__ did not return an integer E0306 (invalid-repr-returned): __repr__ did not return a string E0307 (invalid-str-returned): __str__ did not return a string E0308 (invalid-bytes-returned): __bytes__ did not return a string E0309 (invalid-hash-returned): __hash__ did not return an integer E0310 (invalid-length-hint-returned): __length_hint__ did not return a non-negative integer E0311 (invalid-format-returned): __format__ did not return a string E0312 (invalid-getnewargs-returned): __getnewargs__ did not return a tuple E0313 (invalid-getnewargs-ex-returned): __getnewargs_ex__ did not return a tuple of the form (tuple, dict) Close #560
Originally reported by: Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore)
We could improve the protocol checker, there are a lot of special methods which must return something of a given type in order work properly, other special methods require the presence of another method defined and so on: https://docs.python.org/3/reference/datamodel.html
The text was updated successfully, but these errors were encountered: