That pattern is used almost as much as multi-argument guards. I checked the typings from DefinitelyTyped (JS equivalent of typeshed) and found the following statistics:
7501 packages 100 (1.3%) packages defining type guards 13 (0.17%) packages defining multi-argument type guards 10 (0.13%) packages defining type guards for this (self) On Fri, Feb 12, 2021 at 12:00 AM Guido van Rossum <gu...@python.org> wrote: > I think the use case (for x.is_foo()) is rare. And instead of writing > x.is_foo(x), if you make the guard a function you can write is_foo(x). > > On Thu, Feb 11, 2021 at 6:51 PM Sebastian Kreft <skr...@gmail.com> wrote: > >> I still think that we should reconsider deferring what happens to class >> and instance methods. >> >> The arguments given in https://www.python.org/dev/peps/pep-0647/#id13 >> seem insufficient, specially considering than the workaround provided is >> quite awkward. >> >> The author suggests to write def check(self, self2) -> Typeguard[T] and >> call it as self.check(self). >> _______________________________________________ >> Python-Dev mailing list -- python-dev@python.org >> To unsubscribe send an email to python-dev-le...@python.org >> https://mail.python.org/mailman3/lists/python-dev.python.org/ >> Message archived at >> https://mail.python.org/archives/list/python-dev@python.org/message/CA2MFS4XXDPC6PDBW53BZWLWEMQOBBP6/ >> Code of Conduct: http://python.org/psf/codeofconduct/ >> > > > -- > --Guido van Rossum (python.org/~guido) > *Pronouns: he/him **(why is my pronoun here?)* > <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/> > -- Sebastian Kreft
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/HI3TW2SPJW5XKUYNFPWB5O4J3KZTR2EO/ Code of Conduct: http://python.org/psf/codeofconduct/