Commit db440ab
authored
Don't consider 'object' always truthy (#14510)
There are two reasons I'm proposing this change. First, we know that
many subclasses of 'object' can be falsy. Second, mypy sometimes
simplifies `object | Any` into just `object`. The latter was considered
always truthy, while the prior one wasn't. Now both of them are treated
consistently. An alternative fix would be to not simplify unions like
`object | Any`, but this seems a bit ad hoc.
This only has an effect when the `truthy-bool` error code is explicitly
enabled.
Fixes #14480. This doesn't just fix the regression but fixes a more
general issue.1 parent 77f8725 commit db440ab
2 files changed
+23
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5151 | 5151 | | |
5152 | 5152 | | |
5153 | 5153 | | |
| 5154 | + | |
5154 | 5155 | | |
5155 | 5156 | | |
5156 | 5157 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
803 | 803 | | |
804 | 804 | | |
805 | 805 | | |
| 806 | + | |
806 | 807 | | |
807 | 808 | | |
808 | | - | |
| 809 | + | |
809 | 810 | | |
810 | 811 | | |
811 | 812 | | |
| 813 | + | |
| 814 | + | |
812 | 815 | | |
813 | 816 | | |
814 | 817 | | |
| |||
836 | 839 | | |
837 | 840 | | |
838 | 841 | | |
839 | | - | |
840 | | - | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
841 | 851 | | |
842 | | - | |
| 852 | + | |
843 | 853 | | |
844 | 854 | | |
845 | 855 | | |
846 | 856 | | |
847 | 857 | | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
848 | 866 | | |
849 | 867 | | |
850 | 868 | | |
| |||
0 commit comments