Danny Yang

Results 69 comments of Danny Yang

Yeah, I think this would require implementing https://github.com/facebook/pyrefly/issues/238 + adding a hasattr style narrowing for keys. @xaskii is working on hasattr right now, so I'll probably extend that to support...

So I think the root cause of this is that our contextual subtyping doesn't work super well with unions, but due to the way TypedDicts are handled, it never works...

I would expect global installations to part of the site package paths, and for pyrefly to be able to find it. The error should list which paths it looked in...

Pyrefly not being importable from pip sounds like what we're tracking in https://github.com/facebook/pyrefly/issues/653 I'm glad you were able to get this working with some manual tweaks! But let's see if...

Thanks for reporting! We do not have any special handling for methods on TypedDicts right now, but we'll keep ReadOnly semantics in mind when we do get around to supporting...

https://pyrefly.org/sandbox/?code=MQAg6gpgNgxg9gWwiALnVALZAFAngJwgDMpcQBlAQwDsATAIzgA8AaTASwGcQuRKQADpQDmEAFCgA7lkIhccAK4gYNEJPzsUENpwyVZNWiCgR91PowUpUuAe2rCe5vCgxxqAOgkSQACQgGBsqKAiYgRKYoCoTccEQc3JyGjEwAXD4AtCAA4hDWhJRQGSjsSDYCyDBYMADW9o4REAyUtZkgAKqcyIQAbqZQAPoothAAFACUqOj2nBUw1vYR+IRGwxWcbRBMFRpI1NaSmhiYyACSACIAouGR0RDcrpQHyJwKAgJw+NajEB7CHnwrHB4AhQnltCBhHBitDaMR7Jp2O42G4+vg2HkYOM2mANFo+HQQPgFM5cK53ME4SBaOxCPNSE45Ip8CB6Pg4JIuvgxGIiOyEOV6jxQZ9rAAqHlw+JaTgoUZMAC8ADl3BBxukQJqiRA+oUhiN5eMgA When we have an unannotated param with default=None, we infer `Any`, but I think typeshed would like us to infer `Any | None` https://github.com/python/typeshed/issues/14029

@ndmitchell just wanna make sure i'm on the right track here... Seems like we already support this for simple assignments to variables: https://pyrefly.org/sandbox/?code=GYexC4AICMwG0gXkgFQE4FcCmAoAHkpAIw4CWwkoEOktkByAciAHa5pYBuWAhnAPoAXAJ4AHLAAo8AShxA Jon's feedback seemed related to inserting None...

Here's a non-inheritance example: ``` class C: x = None def __init__(self, x: int | None): if x: self.x = x c = C(None) reveal_type(c.x) ```

I think there's 2 pieces to this: 1. make un-annotated fields inherit annotations from the parent class (I'm not sure which one they should inherit if there's multiple inheritance, but...