-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Be more consistent with Python variable prefixes #1908
Conversation
Some(suffix) => format!("UniffiRustBuffer{suffix}"), | ||
None => "UniffiRustBuffer".to_string(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The underscores were actually added in #1599
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doh!
I just updated the PR to always use the underscores. PEP 8 seems to say we don't need them if we use __all__
, but the autocomplete example from 1599 is pretty convincing to me.
I also updated the names for a few more functions. _rust_call
is now _uniffi_rust_call
5671548
to
b4e8237
Compare
I also added a README for the templates that goes over naming. |
b4e8237
to
a5647f4
Compare
Always use `_uniffi`, `_Uniffi`, or `_UNIFFI` for module-level names. The leading underscore is to indicate private variables and makes it so the names don't appear in autocomplete. I think this is the most Pythonic naming style. Use `_uniffi` rather than simply `_` to avoid name collisions. I think the general contract with our users should be that we own the `uniffi` prefix. If they want to name something `UniffiFoo`, then they take the risk of a name collision.
a5647f4
to
59c17be
Compare
I've been trying to clean up my old branches and finally got around to this one. There's not that much left in this PR, but I think would still be good to merge. WDYT? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like an improvement to me!
Always use
uniffi
,Uniffi
, orUNIFFI
for module-level names. Add a leading underscore for private class members. I think this is the most Pythonic naming style. Because we define__all__
for modules, there's no chance that users will accidentally import the UniFFI items withfrom module import *
Before there were lots of leading underscores, but I don't see the point and it doesn't feel Pythonic to me.
I think the general contract with our users should be that we own the
uniffi
prefix. If they want to name somethingUniffiFoo
, then they take the risk of a name collision.This is my personal take on the matter, but I'm fine with any naming scheme. I just think we should be consistent about it.