[Python-ideas] Introduce typing.SupportsFsPath

Eric Fahlgren ericfahlgren at gmail.com
Thu Oct 11 18:34:15 EDT 2018


Done https://github.com/python/mypy/issues/5775

On Thu, Oct 11, 2018 at 1:47 PM Ivan Levkivskyi <levkivskyi at gmail.com>
wrote:

> On Tue, 9 Oct 2018 at 15:17, Eric Fahlgren <ericfahlgren at gmail.com> wrote:
>
>> On Tue, Oct 9, 2018 at 3:16 AM Ivan Levkivskyi <levkivskyi at gmail.com>
>> wrote:
>>
>>> class PathLike(Protocol[AnyStr]):
>>>
>>
>> I had been working on this same problem intermittently for several
>> months, so thanks, but...
>>
>>     error: Invariant type variable 'AnyStr' used in protocol where
>> covariant one is expected
>>
>> 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?
>>
>
> 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`.
>
> --
> Ivan
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20181011/966de45c/attachment.html>


More information about the Python-ideas mailing list