Eric Traut

Results 355 comments of Eric Traut

Mypy is able to handle this pattern if you make the following small modification to your code. ```python v = Enum("v", "LATEST") LATEST = v.LATEST ``` This approach is preferable...

You seem to misunderstand what `NoReturn` means when used in a return type. It doesn't mean that an function (or overload) cannot be called. It simply means that when called,...

If you have just one or two pieces of state that are initialized at the time that the object is "ready", you can move the logic to individual property accessors....

The upper bound for a TypeVar cannot be generic. It must be concrete. This is spelled out in PEP 484. Since you've specified a bound of `G[anA]`, mypy should generate...

I'm not able to repro the original bug in this bug report using mypy 1.5. Perhaps it was fixed in a recent release, or perhaps the pydantic library has changed...

@K1T3K1, as @sobolevn said, it's difficult to follow your bug report above. Could you provide a minimal self-contained code sample that demonstrates the problem you're seeing?

@ikonst, yes, the behavior you're seeing here in pyright is the result of the "ambiguous solution scoring" heuristics in its constraint solver. A union that includes an `Any` is unusual...

Mypy appears to be implementing `TypeGuard` support correctly here. In `failing_in_both`, the revealed type should be `int | list` because that's what the `int_or_list` type guard function specifies. The `working_in_pyright`...

Is there a need to support this idiom? The `typing_extensions` library already provides a backward-compatibility abstraction and uses `typing.TypeAlias` if it's available, so the above code could be simplified to...

I'm not able to repro the problem with the latest version of mypy. But then again, I'm not able to repro with any versions going back to 0.990, so maybe...