Repository navigation
Commit 0a9e750
committed
added boolean condition warnings: overlap, redundancy,
three ty lints on truthiness tests:
- `overlapping-condition` — the branch a condition selects is reached by
more than one kind of member, so it cannot tell them apart. only the
selected branch is analysed (`if a` truthy, `if not a` falsy), and
members of one class (or two where one derives the other) count as one
kind
- `redundant-condition` — the tested value's own type fixes the outcome.
restricted to a value read: ty folding a comparison or call is the
statically-known-branch machinery doing its job
- `redundant-boolean-comparison` — `a == True` where `a` is a `bool`
`ConditionTruthiness` adds a fourth state to `Truthiness`: artificial,
for a constant the checker's model of the build produced rather than the
program's types — `TYPE_CHECKING`, `sys.version_info`, `sys.platform`,
`os.name`. a redundant-condition report on one of those would be wrong
two options tune the overlap check:
`analysis.overlapping-condition-exempt-types` drops members of the named
classes, and `analysis.overlapping-condition-assume-truthy-instances`
takes a class with no `__bool__`/`__len__` at face value== True
1 parent e357026 commit 0a9e750
41 files changed
Lines changed: 2233 additions & 165 deletions
File tree
- crates
- ruff_db/src/diagnostic
- ty_project/src/metadata
- ty_python_semantic
- resources/mdtest
- boundness_declaredness
- diagnostics
- function
- loops
- narrow
- conditionals
- snapshots
- src
- types
- infer
- builder
- ty_server/tests/e2e/snapshots
- ty_test/src
- ty
- docs
- tests/cli
- docs/basedpython/features
- scripts
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1009 | 1009 | | |
1010 | 1010 | | |
1011 | 1011 | | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
1012 | 1033 | | |
1013 | 1034 | | |
1014 | 1035 | | |
| |||
1137 | 1158 | | |
1138 | 1159 | | |
1139 | 1160 | | |
| 1161 | + | |
1140 | 1162 | | |
1141 | 1163 | | |
1142 | 1164 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments