> On Dec 14, 2025, at 3:07 PM, via Twisted <[email protected]> wrote:
> 
> Hi, I am trying to learn twisted, and heavily relying on examples to learn.
> The last example on this page 
> https://docs.twisted.org/en/twisted-18.7.0/core/howto/pb-cred.html doesn't 
> work, is that because of the switch from python 2 to python 3, because of the 
> new distinction between strings in byte strings ? If so, is that a bug or is 
> there a workaround to make the example code work ?

Yes, this is most likely broken because we don't have test coverage, or even 
type checking, for our documentation. Sorry for the trouble.

If I run `mypy docs/core/howto/listings/pb/chatserver.py` in a checkout of 
current trunk, I see a bunch of errors, but most of them are related to the 
example itself not being annotated.  However, there are many errors like this:

docs/core/howto/listings/pb/chatserver.py:70:17: error: Argument 1 to "addUser" 
of "InMemoryUsernamePasswordDatabaseDontUse" has incompatible type "str"; 
expected "bytes"  [arg-type]
docs/core/howto/listings/pb/chatserver.py:70:26: error: Argument 2 to "addUser" 
of "InMemoryUsernamePasswordDatabaseDontUse" has incompatible type "str"; 
expected "bytes"  [arg-type]

which suggests that a couple of `b` prefixes on some of those strings might fix 
it.

The source for this example is here: 
https://github.com/twisted/twisted/blob/trunk/docs/core/howto/listings/pb/chatserver.py

Would you have any interest in submitting a small pull request to fix it?  You 
don't need to add automated test coverage for the example, given that none 
exists currently, and it might be a hassle to set up a testing environment for 
that just to fix a couple of small type issues.

Thanks,

-g

> Thank you in advance.
> _______________________________________________
> Twisted mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/twisted.python.org/
> Message archived at 
> https://mail.python.org/archives/list/[email protected]/message/KER632VC7756ZUP2VOHX2UJ3H7PK7LN6/
> Code of Conduct: https://twisted.org/conduct

_______________________________________________
Twisted mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/twisted.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/COKGCVU4TFMRO5A45IQ3OOYNMH3LD5OS/
Code of Conduct: https://twisted.org/conduct

Reply via email to