facebook / facebook/pyrefly

pyrefly can't find attribute `__weakref__` of cls in __init_subclass__

Open
#369 3 comments 0 reactions 0 assignees View on GitHub
typeshed
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug

When running the code snippet
```
from typing import *

class Base():
def __init_subclass__(cls, **kwargs):
print(cls.__name__)
print(cls.__type_params__)
print(cls.__qualname__)
print(cls.__weakref__)

class Sub(Base):
...
```

in Pyrefly I get the error
``ERROR 14:15-27: Object of class `Base` has no attribute `__name__` [[missing-attribute](https://pyrefly.org/en/docs/error-kinds/#missing-attribute)]``

for each attribute.

I didn't tried now all dunder attributes but it seems to be the ones which are missing in dir(Base)

### Sandbox Link

https://pyrefly.org/sandbox/?code=MQAg6gpgNgxg9gWwiALnVALZAFAngJwgDMpcQBlAQwDsATAIzgA8AaTASwGcQuRKQADpQDmEAFCgA7lkIhccAK4gYNEJPzsUENpwyVZNWiCgR91PowUpUuAe2rCe5vCgxxqAOgkSQACQgGBsqKAiYgRKYoCoTccEQc3JyGjEwAXD4AtCAA4hDWhJRQGSjsSDYCyDBYMADW9o4REAyUtZkgAKqcyIQAbqZQAPoothAAFACUqOj2nBUw1vYR+IRGwxWcbRBMFRpI1NaSmhiYyACSACIAouGR0RDcrpQHyJwKAgJw+NajEB7CHnwrHB4AhQnltCBhHBitDaMR7Jp2O42G4+vg2HkYOM2mANFo+HQQPgFM5cK53ME4SBaOxCPNSE45Ip8CB6Pg4JIuvgxGIiOyEOV6jxQZ9rAAqHk8mBQSicbgAIVlY3G6RAaupxBAAwGCJQA1e9Glss42tG0s4bDFYpqkn0wk4KrE6udgg0+zNUE4Hm11EoSG12Jd6oEbpQHq92rWEAGQnwfpNA0DQdd9jD5u9AwAjgpCr7-YmncmQ6nwxnJKYaoQiAGpTK5RQFPRRoquo7nR4O2IgA

### (Only applicable for extension issues) IDE Information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.