[ty] Add Flag and IntFlag support#26289
Closed
charliermarsh wants to merge 16 commits into
Closed
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 94.47%. The percentage of expected errors that received a diagnostic held steady at 89.10%. The number of fully passing files held steady at 95/134. |
Memory usage reportSummary
Significant changesClick to expand detailed breakdownprefect
sphinx
trio
flake8
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
unsupported-operator |
0 | 0 | 2 |
| Total | 0 | 0 | 2 |
Flaky changes detected. This PR summary excludes flaky changes; see the HTML report for details.
Raw diff:
core (https://github.com/home-assistant/core)
- homeassistant/components/hunterdouglas_powerview/cover.py:368:9 error[unsupported-operator] Operator `|=` is not supported between objects of type `None` and `Literal[CoverEntityFeature.OPEN_TILT]`
+ homeassistant/components/hunterdouglas_powerview/cover.py:368:9 error[unsupported-operator] Operator `|=` is not supported between objects of type `None` and `CoverEntityFeature`
- homeassistant/components/velux/cover.py:242:9 error[unsupported-operator] Operator `|=` is not supported between objects of type `None` and `Literal[CoverEntityFeature.OPEN_TILT]`
+ homeassistant/components/velux/cover.py:242:9 error[unsupported-operator] Operator `|=` is not supported between objects of type `None` and `CoverEntityFeature`9ca4e30 to
b619ccc
Compare
24d5c90 to
ede8303
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR is stacked on #26277, which models
FlagandIntFlagmember sets as non-exhaustive. It adds the semantic support needed to reason about their runtime values without enumerating every possible flag combination.We build a cached Flag profile containing the member type, declared integer masks, canonical iteration members, boundary policy, and the information needed to construct exact named results. We use that profile for
auto()values, constructors, bitwise operations, inversion, truthiness, length, instance iteration, and subset membership, including classes created with the functional enum syntax.For example, named results remain literals while unnamed combinations remain nominal Flag values:
The implementation also models
STRICT,CONFORM,EJECT, andKEEP; preserves pre-3.11auto(), inversion, negative-value, and inherited-operator behavior; and respects custom member types, metaclass calls,_missing_, reflected operators, and iteration hooks. When those hooks or member values make the runtime result unknowable, we retain the existing conservative fallback instead of applying the exact Flag path.