-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
get_default_session() should be public #2707
Comments
Here is a temporary solution that you're probably already aware of: (essentially a re-write of _get_default_session())
I'm new to the project and had to do some digging, but it appears that DEFAULT_SESSION is initialized in the setup_default_session() function. If it is not initialized, the first if statement should fail, leading you to the setup_default_session() function without worry of overwriting some already existing custom value. This is a temporary fix I know, and I'm there with you, _get_default_session() should be public. Hopefully this helps, please let me know if there's anything I missed! |
I just use |
I'm primarily a C programmer, so I didn't even think twice about the mention of private/public! I believe this is a primary reason as to why I love to attempt to assist others on Stack Overflow and GitHub, I end up learning a lot myself! It seems as though private and public is, like you say, for documentation, much like ':' in parameters and '->' in function declarations. I'm curious why the Boto package doesn't use these operators for further documentation? Perhaps the extensive use of pointers makes it unnecessary? Thank you Ben, and my earlier comment has been modified to show the changes I should've noticed myself. |
Type hints were introduced in Python 3.5 (see PEP 484). boto3 currently still supports Python 2.7, and the code would have a syntax error in 2.7 if there were type hints. While support for Python 3.4 and 3.5 is ending, and Python 2.7 is officially at its end of life, I have not seen that boto3 intends to remove support for it yet. You can add type annotations in your own code using the 3rd party |
Is this still being considered? |
I'd still love to see it! |
I would still love to see this! It's a minor change, but means a lot stylistically in production settings. The change in the linked pull request would not break existing code due to aliasing. If the feature is not being considered at all, it would be great to hear a rationale or something. |
Currently,
DEFAULT_SESSION
andsetup_default_session()
are public members ofboto3
module, but the caching_get_default_session()
is not. I'd like to see this changed. I often write functions that look likesome people write this as
but this breaks if I'm doing anything other than creating a client.
I can't write the following because it might not be initialized:
I can't write the following because
DEFAULT_SESSION
might have been initialized to a custom value already:I could copy in the logic from
_get_default_session()
(which only callssetup_default_session()
ifDEFAULT_SESSION
isn't initialized) into each place where I do this, but why make me do that?There doesn't seem to be any good reason for it to be private, especially given that the fields it operates on are public. I'd ask for the function to be renamed
get_default_session()
and an alias_get_default_session = get_default_session
to be added for backward compatibility.The text was updated successfully, but these errors were encountered: