Commit 7df2cd6
flag ambiguous protocol members without type annotations (#3012)
Summary:
- add new `UnannotatedProtocolMember` error kind for protocol members assigned a value without an explicit type annotation
- matches mypy behavior - protocol members must have declared types
- updates existing bug test case to verify the new diagnostic fires correctly
Pull Request resolved: #3012
Test Plan:
- updated `test_protocol_ambiguous_member` to expect the new error on unannotated assignments like `x = None`
- added positive case (`class Ok(Protocol)`) with annotated members to confirm no false positives
- all 34 existing protocol tests still pass
fixes #2925
Reviewed By: rchen152
Differential Revision: D100014044
Pulled By: stroxler
fbshipit-source-id: 41fe7b177036511fdbf708a6cf9b84077b03d1111 parent 305dfc9 commit 7df2cd6
File tree
4 files changed
+37
-5
lines changed- crates/pyrefly_config/src
- pyrefly/lib
- alt/class
- test
- website/docs
4 files changed
+37
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
| 262 | + | |
| 263 | + | |
262 | 264 | | |
263 | 265 | | |
264 | 266 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1588 | 1588 | | |
1589 | 1589 | | |
1590 | 1590 | | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
1591 | 1605 | | |
1592 | 1606 | | |
1593 | 1607 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1008 | 1008 | | |
1009 | 1009 | | |
1010 | 1010 | | |
1011 | | - | |
1012 | 1011 | | |
1013 | 1012 | | |
1014 | 1013 | | |
1015 | 1014 | | |
1016 | 1015 | | |
1017 | | - | |
1018 | | - | |
1019 | | - | |
1020 | | - | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
1021 | 1022 | | |
1022 | 1023 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1264 | 1264 | | |
1265 | 1265 | | |
1266 | 1266 | | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
1267 | 1282 | | |
1268 | 1283 | | |
1269 | 1284 | | |
| |||
0 commit comments