Skip to content

Conversation

jthistle
Copy link
Contributor

Normally, SimpleClient.transport has signature () -> str. However, if SimpleClient.connect() is not called SimpleClient.transport is simply a str (not a function).

I came across this as this was confusing the Pylance type checker.

My proposed fix ensures reasonable behaviour by always making SimpleClient.transport a function. It shouldn't break anything important since SimpleClient.transport is meaningless before connect is called anyway. However, this is not a strictly backwards-compatible change.

@miguelgrinberg
Copy link
Owner

Thanks! The correct fix here, however, is to address the incorrect return type, which is documented as a string, but was inadvertently being returned as a callable.

@jthistle
Copy link
Contributor Author

jthistle commented Sep 29, 2025

Ok, cool. I might be wrong, but won't doing that break backwards compatability for user code in a worse way, since now all calls to SimpleClient.transport() will raise exceptions? Why not just update the docstring instead?

Also, I'm not sure the docstring was necessarily incorrect as SimpleClient.transport() did return a string, which was just as it stated.

Sorry if I'm not understanding this properly!

@miguelgrinberg
Copy link
Owner

This issue cannot be fixed in a backwards compatible manner. As I said above, the return value was not in agreement with the documented way this property works, and if backwards compatibility is going to be broken regardless of the fix, I rather fix the bug propertly instead of perpetuating an old mistake that I've made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants