Conversation
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
type-assertion-failure |
1 | 35 | 0 |
unresolved-attribute |
2 | 13 | 2 |
invalid-argument-type |
8 | 2 | 5 |
possibly-unbound-attribute |
0 | 10 | 1 |
invalid-assignment |
7 | 0 | 1 |
unused-ignore-comment |
0 | 7 | 0 |
call-non-callable |
4 | 0 | 0 |
invalid-return-type |
0 | 0 | 2 |
subclass-of-final-class |
1 | 0 | 0 |
| Total | 23 | 67 | 11 |
| # TODO: This should not be an error. The return type should be `A | B | C` once enums are expanded | ||
| # error: [no-matching-overload] | ||
| reveal_type(f(x)) # revealed: Unknown |
There was a problem hiding this comment.
I have not implemented expansion of enums yet. I didn't see any ecosystem impact (no new no-matching-overload diagnostics or similar), so I guess this change is fine. Returning Unknown instead of A seems better anyway.
This comment was marked as off-topic.
This comment was marked as off-topic.
2fa37d4 to
cfae2bc
Compare
crates/ty_python_semantic/resources/mdtest/type_properties/truthiness.md
Show resolved
Hide resolved
crates/ty_python_semantic/resources/mdtest/type_properties/is_single_valued.md
Show resolved
Hide resolved
fa5a5ee to
76a9bac
Compare
CodSpeed Instrumentation Performance ReportMerging #19328 will degrade performances by 5.69%Comparing Summary
Benchmarks breakdown
|
crates/ty_python_semantic/resources/mdtest/narrow/conditionals/eq.md
Outdated
Show resolved
Hide resolved
|
hmm, could the codspeed complaints be due to the changes to |
No, I'm afraid it might be due to the new |
ef50d99 to
9ee7fe9
Compare
9ee7fe9 to
d0060c2
Compare
I did find a way to reduce the regression from -8% to -5% in the I don't think that small regressions on these benchmarks are a huge deal, and all other benchmarks are below -2%, so I'm not going to investigate much further. Not because I'm out of ideas, but because it starts to feel like there are more important things to do. If someone disagrees, please let me know. Happy to take another look. |
* main: [ty] Enum literal types (astral-sh#19328)
Summary
Add a new
Type::EnumLiteral(…)variant and infer this type for member accesses on enums.Example: No more
@Todotypes here:Test Plan
Ecosystem analysis
Lots of false positives removed. All of the new diagnostics are either new true positives (the majority) or known problems. Click for detailed analysis
New true positives. That
__getitem__method is apparently annotated withNeverto prevent developers from using it.Arguably true positives: https://github.com/DataDog/dd-trace-py/blob/e0a772c28bc3897a4b5df73125274999e0f58f30/ddtrace/vendor/psutil/_common.py#L29
All true positives. Some of them are inside
pytest.raises(TypeError, …)blocks 🙃New true positives. Enum literals can not be assigned to
bool, even if their value types are0and1.poetry (https://github.com/python-poetry/poetry) + error[invalid-assignment] src/poetry/console/exceptions.py:101:5: Object of type `Literal[""]` is not assignable to `InitVar[str]`New false positive, missing support for
InitVar.prefect (https://github.com/PrefectHQ/prefect) + error[invalid-argument-type] src/integrations/prefect-dask/tests/test_task_runners.py:193:17: Argument is incorrect: Expected `StateType`, found `Literal[StateType.COMPLETED]`This is confusing. There are two definitions (one, two) of the
StateTypeenum. Here, we're trying to assign one to the other. I don't think that should be allowed, so this is a true positive (?).True positives. The stubs are wrong. These should not contain type annotations, but rather just
OFF = ....rotki (https://github.com/rotki/rotki) + error[invalid-argument-type] rotkehlchen/tests/unit/test_serialization.py:62:30: Argument to bound method `deserialize` is incorrect: Expected `str`, found `Literal[15]`New true positive.
Also new true positives. No
DEFAULTmember exists onWeightsEnum.