<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="color:rgb(0,0,0)">Done <a href="https://github.com/python/mypy/issues/5775">https://github.com/python/mypy/issues/5775</a></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Oct 11, 2018 at 1:47 PM Ivan Levkivskyi <<a href="mailto:levkivskyi@gmail.com">levkivskyi@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Tue, 9 Oct 2018 at 15:17, Eric Fahlgren <<a href="mailto:ericfahlgren@gmail.com" target="_blank">ericfahlgren@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div style="color:rgb(0,0,0)"><span style="color:rgb(34,34,34)">On Tue, Oct 9, 2018 at 3:16 AM Ivan Levkivskyi <<a href="mailto:levkivskyi@gmail.com" target="_blank">levkivskyi@gmail.com</a>> wrote:</span><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">class PathLike(Protocol[AnyStr]):<br></div></div></div></blockquote><div> </div><div><div style="color:rgb(0,0,0)">I had been working on this same problem intermittently for several months, so thanks, but...</div><br></div><div style="color:rgb(0,0,0)">    error: Invariant type variable 'AnyStr' used in protocol where covariant one is expected</div><div style="color:rgb(0,0,0)"><br></div><div style="color:rgb(0,0,0)">is called out on the class  by mypy 0.630 (Python 3.6.6).  Do I just need to wait for 0.640?  Or should I define a new TypeVar for AnyStr_co and use that?</div></div></div></div></blockquote><div><br></div><div>Hm, it looks like mypy overreacts here. I think it should be safe to use a constrained type variable if there are no constraints that are subtypes of other constraints (which is the case for AnyStr on Python 3, where bytes is not a subtype of str). Could you please open an issue about this on mypy tracker? In the meantime, you can just silence the error with a `# type: ignore`.</div><div><br></div><div>--</div><div>Ivan</div><div><br></div><div><br></div></div></div>
</blockquote></div>