Carl Meyer

Results 478 comments of Carl Meyer

Actually I think unions and intersections might provide an interesting generalized path forward here. In a scope where we don't consider arbitrary external mutation mid-execution to be possible (this is...

Red-knot already has intersections as a core part of our type model. All of our type narrowing is implemented exclusively through intersections and reduction of intersections. Our intersections behave as...

I created https://github.com/astral-sh/ty/issues/126 for follow-up on whether red-knot should honor the external mutation possibility.

> I am personally sympathetic to the viewpoint where an explicit cast is required for potentially-unsafe operations. I am too, but I'm not sure how this applies to example 1...

I don't think that is a sustainable interpretation of what it means for an operation to be "safe" or "unsafe" in gradual typing. Under that interpretation, essentially _all_ usage of...

> I have to admit that I never thought of it this way, but rather the opposite: I thought the purpose of gradual typing was to give you a tool...

The idea that `x: str = returns_any()` might be intended to apply some static typing safety at the boundary with an untyped library is a really good point. In general,...

I feel somewhat strongly about `isinstance(x, str)` from `x` as `Any` narrowing to `str & Any` (which will basically behave like `Any`), not to `str`, because the latter is not...

`TypeIs` at least should not be too difficult to build on top of our existing narrowing support; tagging "help wanted" for that. `TypeGuard` may be somewhat more challenging, since it...