You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
consistently skip bad-return validation for stub methods (#1965)
Summary:
We now consistently skip implicit return validations for all stub functions, which are functions that fit both these criteria:
1. are defined inside a protocol class body OR decorated w/ abstract method/overload
2. have trivial bodies like pass/return NotImplemented, raise NotImplementedError, or ... (the body may only be a docstring, or have a docstring before its first statement)
We will now error for non-stub functions that have `...` as the body
Fixes#1916Fixes#2159
Pull Request resolved: #1965
Test Plan:
- Added `test_protocol_method_with_docstring` test case covering:
- `property` with docstring only
- Regular method with docstring only
- Method with `pass`
- Method with ellipsis (already worked)
- Verified regular (non-Protocol) classes still error correctly
- Ran `python3 test.py` - all tests pass
- Ran `cargo test --lib protocol::` - all 37 protocol tests pass
Reviewed By: stroxler
Differential Revision: D90340690
Pulled By: yangdanny97
fbshipit-source-id: c070e7e7611552ec490fb87fcca988203962ca10
0 commit comments