Commit 37e61f1
authored
[codex] Improve tuple diagnostics and weak container assignability (#449)
## Summary
This PR improves two related pieces of relation checking.
- preserve the detailed element-level error from tuple-to-tuple
comparisons instead of collapsing it to `tuple is not assignable to
tuple`
- allow strong containers like `list[T]` and `set[T]` to satisfy weak
container literals in the invariant reverse direction when the weak
container could still be empty and all unpacked members accept `T`
- cover the taxonomy-shaped `defaultdict(lambda: ([], []))` case with
low-level regression tests
## Why
The tuple diagnostics change fixes a usability issue where nested tuple
mismatches lost the useful positional explanation produced deeper in the
relation machinery.
The weak-container change fixes a false positive in taxonomy where
annotated tuple values containing strong `list[ClassificationEntry]`
entries were rejected against weak empty-list literals inferred from
`defaultdict(lambda: ([], []))`.
## Impact
Users now get more actionable tuple mismatch errors, and pycroscope
accepts more realistic nested container patterns involving empty list or
set literals without weakening the ordinary
weak-literal-to-strong-container direction.
## Validation
- `UV_CACHE_DIR=/tmp/uv-cache uv run --python 3.14 --extra tests pytest`
- `UV_CACHE_DIR=/tmp/uv-cache uv run --python 3.14 --extra tests pytest
pycroscope/test_value.py pycroscope/test_relations.py`
- `UV_CACHE_DIR=/tmp/uv-cache uv run --python 3.14 python
tools/taxonomy_ci.py --local-path /Users/jelle/Dropbox/code/taxonomy
--install | rg "taxonomy/db/export.py at line 741|taxonomy/db/export.py
at line 786|list\[ClassificationEntry\] is not assignable to <list
containing \[\]>"`1 parent e95bedf commit 37e61f1
3 files changed
Lines changed: 120 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
885 | 885 | | |
886 | 886 | | |
887 | 887 | | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
888 | 916 | | |
889 | 917 | | |
890 | 918 | | |
| |||
922 | 950 | | |
923 | 951 | | |
924 | 952 | | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
925 | 962 | | |
926 | 963 | | |
927 | 964 | | |
| |||
1787 | 1824 | | |
1788 | 1825 | | |
1789 | 1826 | | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
1790 | 1832 | | |
1791 | 1833 | | |
1792 | 1834 | | |
1793 | 1835 | | |
| 1836 | + | |
| 1837 | + | |
1794 | 1838 | | |
1795 | 1839 | | |
1796 | 1840 | | |
1797 | 1841 | | |
1798 | 1842 | | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
1799 | 1848 | | |
1800 | 1849 | | |
1801 | 1850 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
395 | 396 | | |
396 | 397 | | |
397 | 398 | | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
398 | 467 | | |
399 | 468 | | |
400 | 469 | | |
| |||
0 commit comments