[ty] Support @classmethod and @staticmethod protocol members#26331
Draft
charliermarsh wants to merge 39 commits into
Draft
[ty] Support @classmethod and @staticmethod protocol members#26331charliermarsh wants to merge 39 commits into
@classmethod and @staticmethod protocol members#26331charliermarsh wants to merge 39 commits into
Conversation
f94a50c to
2b1d82c
Compare
fe5b312 to
6a4d154
Compare
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 94.44%. The percentage of expected errors that received a diagnostic held steady at 90.21%. The number of fully passing files held steady at 95/134. |
Memory usage reportMemory usage unchanged ✅ |
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
no-matching-overload |
30 | 0 | 0 |
invalid-argument-type |
10 | 0 | 0 |
| Total | 40 | 0 | 0 |
Flaky changes detected. This PR summary excludes flaky changes; see the HTML report for details.
Raw diff (40 changes)
pycryptodome (https://github.com/Legrandin/pycryptodome)
+ lib/Crypto/Cipher/PKCS1_OAEP.py:73:49 error[invalid-argument-type] Argument is incorrect: Expected `Hash | HashModule`, found `Unknown | <module 'Crypto.Hash.SHA1'>`
+ lib/Crypto/SelfTest/Cipher/test_pkcs1_oaep.py:291:40 error[invalid-argument-type] Argument to function `new` is incorrect: Expected `HashLikeClass | None`, found `<module 'Crypto.Hash.SHA1'>`
+ lib/Crypto/SelfTest/Cipher/test_pkcs1_oaep.py:308:40 error[invalid-argument-type] Argument to function `new` is incorrect: Expected `HashLikeClass | None`, found `<module 'Crypto.Hash.SHA1'>`
+ lib/Crypto/SelfTest/Cipher/test_pkcs1_oaep.py:342:49 error[invalid-argument-type] Argument to function `new` is incorrect: Expected `HashLikeClass | None`, found `<module 'Crypto.Hash.MD2'> | <module 'Crypto.Hash.MD5'> | <module 'Crypto.Hash.SHA1'> | <module 'Crypto.Hash.SHA256'> | <module 'Crypto.Hash.RIPEMD160'>`
+ lib/Crypto/SelfTest/Cipher/test_pkcs1_oaep.py:416:48 error[invalid-argument-type] Argument is incorrect: Expected `Hash | HashModule`, found `<module 'Crypto.Hash.SHA1'>`
+ lib/Crypto/SelfTest/Cipher/test_pkcs1_oaep.py:418:48 error[invalid-argument-type] Argument is incorrect: Expected `Hash | HashModule`, found `<module 'Crypto.Hash.SHA224'>`
+ lib/Crypto/SelfTest/Cipher/test_pkcs1_oaep.py:420:48 error[invalid-argument-type] Argument is incorrect: Expected `Hash | HashModule`, found `<module 'Crypto.Hash.SHA256'>`
+ lib/Crypto/SelfTest/Cipher/test_pkcs1_oaep.py:422:48 error[invalid-argument-type] Argument is incorrect: Expected `Hash | HashModule`, found `<module 'Crypto.Hash.SHA384'>`
+ lib/Crypto/SelfTest/Cipher/test_pkcs1_oaep.py:424:48 error[invalid-argument-type] Argument is incorrect: Expected `Hash | HashModule`, found `<module 'Crypto.Hash.SHA512'>`
scrapy (https://github.com/scrapy/scrapy)
+ tests/test_spidermiddleware_start.py:13:14 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_spidermiddleware_start.py:30:14 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ scrapy/core/scheduler.py:450:16 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ scrapy/core/scheduler.py:464:13 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_downloader_handler_twisted_ftp.py:70:14 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_downloader_handlers.py:123:28 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_downloader_handlers.py:164:23 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_downloader_handlers.py:189:18 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_downloader_handlers.py:316:9 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_downloader_handlers.py:322:28 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_downloadermiddleware_redirect.py:399:19 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_downloadermiddleware_redirect.py:419:10 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_downloadermiddleware_redirect.py:433:10 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_downloadermiddleware_redirect.py:456:10 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_downloadermiddleware_redirect_metarefresh.py:146:10 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_extension_throttle.py:42:9 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_extension_throttle.py:45:13 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_extension_throttle.py:59:9 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_extension_throttle.py:84:10 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_extension_throttle.py:101:10 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_extension_throttle.py:150:10 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_extension_throttle.py:176:10 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_extension_throttle.py:206:10 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_extension_throttle.py:242:10 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_extension_throttle.py:274:10 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_extension_throttle.py:296:10 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_extension_throttle.py:326:10 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_pqueues.py:296:13 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_spidermiddleware_depth.py:69:14 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
+ tests/test_spidermiddleware_urllength.py:54:9 error[no-matching-overload] No overload of function `build_from_crawler` matches arguments
static-frame (https://github.com/static-frame/static-frame)
+ static_frame/test/unit/test_bus.py:665:53 error[invalid-argument-type] Argument to function `StoreConfigMap.from_frames` is incorrect: Expected `FromFrameProtocol[StoreConfigBase]`, found `<class 'StoreConfigSQLite'>`6a4d154 to
3ecc9e2
Compare
28a6e0f to
2a7943d
Compare
f14590d to
68f7883
Compare
2a7943d to
d342416
Compare
68f7883 to
03ebd60
Compare
d342416 to
0b9d0b6
Compare
900a097 to
8cc09bf
Compare
0b9d0b6 to
d1111c4
Compare
Merging this PR will degrade performance by 6.68%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression with the CodSpeed MCP and your agent. Comparing Footnotes
|
5c6e1ad to
dde5560
Compare
d1111c4 to
f8556ec
Compare
dde5560 to
8f86bcf
Compare
f8556ec to
cf12531
Compare
385851c to
0e47141
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR builds on #25332 to add support for protocol members declared with
@classmethodor@staticmethod.We now distinguish regular instance methods from class/static methods when deriving a protocol member's access capabilities. A regular method exposes a bound callable through an instance and an unbound callable through the class; a classmethod or staticmethod exposes the same descriptor-resolved callable through both. This lets us check both access paths without treating decorated methods as
Todo.Classmethods and staticmethods are structurally equivalent when their exposed signatures match, so either can satisfy either protocol form:
The same model supports overloaded decorated methods and binds
Selfto the implementation type. Regular instance methods do not satisfy these members because their class-level access remains unbound. Generaltype[P]and meta-protocol support remains outside the scope of this change.