Files
openide/python/testData/intentions
Mikhail Golubev c13b42f56c PY-82454 When a generic class is not parameterized in a type hint, parameterize it with defaults right away
Previously, we parameterized it in PyReferenceExpressionImpl#getTypeFromTarget
and PyFunctionImpl#analyzeCallType, but this substitution disregarded default types
and substituted free type parameters only with their bounds if those were present,
additionally diluting them with `Any` through a "weak type".

So if we had something like the following:

```
class Ref[T : str = str]:
    def get_self(self) -> Self: ...
    def get_type_param(self) -> T: ...

x: Ref = ...
x.get_self()  # Ref[str | Any]
x.get_type_param() # str | Any
```

it worked somewhat correctly only if the omitted type parameter had a bound
in addition to the default.

One notable example from the standard library is the `open()` builtin
returning `TextIOWrapper` that has a default type parameter `_WrappedBuffer`.
This type parameter ended up either substituted with a "weak type" `_WrappedBuffer | Any`
or completely erased.

This change allowed removing special-casing for Self in PyFunctionImpl#analyzeCallType.

GitOrigin-RevId: 6408d24186bf607a08006f15b380e1eb158e63eb
2025-07-18 17:46:54 +00:00
..