pyrefly icon indicating copy to clipboard operation
pyrefly copied to clipboard

`__name__` is reported as being missing from `type` of `NewType`

Open DanielNoord opened this issue 3 months ago • 2 comments

Describe the Bug

from typing import NewType

Thing = NewType("Thing", int)
ThingType = type[Thing]

def func(x: ThingType  )    -> None:
    print(x.__name__)

func(Thing)

Python: 3.12

Likely related to https://github.com/facebook/pyrefly/issues/1709, but __name__ is (I think) almost always available so could potentially be special cased to always work?

Sandbox Link

https://pyrefly.org/sandbox/?project=N4IgZglgNgpgziAXKOBDAdgEwEYHsAeAdAA4CeSIAxlKnHAAQCCiAOuvR-ZjGPWAK7pKACjgwoYADT18iehHQAXAJT0AtAD56AOVzoYcwkbbVaDAELDGy1u07deAoaPFT6AfTkKV6rbv2GxuggkiD8itBwJOSIIADE9ACqEVAQiqR8gpQRenBsbA58uABOALaoiu7o-KXYMMXCsvJKqpr0cIrFtpz0xTCK-MXsYCwg2jV1XfTA%2BAC%2Bo2whIGR9YFCkhIq4pVAUCQAKpKvr7Rg4BPSUepAA5oMVEHqEbAkAyjAw9AAWiorEcIgAPSAlY8daEEo3QEwdCAzC4ShwQFXdC3e45WFFYr0VAAN1Q0FQ2Fgl2uEDuxQeenouGIGKibDIii%2BejUuPqcEe7AAvPRRgBmQgARgATAtgrNQqhshB2QAxaAwChoLB4IhkECzIA

(Only applicable for extension issues) IDE Information

No response

DanielNoord avatar Nov 28 '25 12:11 DanielNoord

I think it is simply missing from typeshed. I just made a PR. https://github.com/python/typeshed/pull/15092

guoci avatar Nov 28 '25 22:11 guoci

thanks @guoci ! I'll update our bundled typeshed next week

yangdanny97 avatar Nov 29 '25 15:11 yangdanny97