On Fri, 21 Apr 2023 at 22:57, Jordan Macdonald <macdj...@gmail.com> wrote:
> However, I then encountered an issue: I could define a Protocol that 
> specified the 'stop()' method easily enough, but if I annotated the manager 
> as taking that, it would accept any class which implemented a method named 
> 'stop()', which was not correct; the manager should only accept threads which 
> implement such a method.
>

To what extent is that actually a problem? Does it need any other
features of the thread? My guess is that, after stopping the thread,
it may want to join() it; in that case, what you could do is add join
to the Protocol. Or whatever else is needed.

You're trying to hybridize duck typing and inheritance typing, which
seems odd. It should be possible to pick one or the other here.

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/QTKLFHVPDVB34EZVYXCWXSAU7N7UVSAL/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to