[proxy] web.archive.org← back | site home | direct (HTTPS) ↗ | proxy home | ◑ dark◐ light

Make logic around bind_self() consistent in different code paths by ilevkivskyi · Pull Request #8021 · python/mypy

ilevkivskyi

The Wayback Machine - http://web.archive.org/web/20200311174713/https://github.com/python/mypy/pull/8021

Conversation

ilevkivskyi merged commit 1122fc6 into python:master

Nov 27, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded

Details

continuous-integration/travis-ci/pr The Travis CI build passed

Details

ilevkivskyi deleted the ilevkivskyi:freshen-classmethod branch

Nov 27, 2019

Merged

ilevkivskyi added a commit that referenced this pull request

Nov 29, 2019
This is a follow up for #8021, that applies the fix also to non-callable types. Currently non-callable types are still wrong:
```python
R = TypeVar('R')
T = TypeVar('T')
# Can be any decorator that makes type non-callable.
def classproperty(f: Callable[..., R]) -> R: ...

class C(Generic[T]):
    @classproperty
    def test(self) -> T: ...

x: C[int]
y: Type[C[int]]
reveal_type(x.test)  # Revealed type is 'int', OK
reveal_type(y.test)  # Revealed type is 'T' ???
```

So, #7724 strikes again. It turns out there is not only duplicated logic for attribute kinds (decorators vs normal methods), but also for callable vs non-callable types. In latter case we still need to expand the type (like in other places, e.g., `analyze_var`).

Closed