-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
Add Typing to args and class attributes #16
Comments
aiogoogle/examples/auth/oauth2.py Lines 28 to 41 in 4eef158
I can see However, in docstring: Lines 30 to 36 in 4eef158
Which then makes linter to give false warning like below: Previously I thought adding So only viable option would be making proper annotations, I'll try to make PL if I manage to annotate it later on. |
Hmmm, interesting. The reason I added the ClientCreds model in the docstring in the first place was to have it documented in the docs. The ClientCreds model inherits from dict. Probably not best practice. But I'm open to changing it as long as everything is backwards compatible. Thanks! |
Yeah feel free to make this change. As long as getitem/setitem methods work
and values can be accessed using this syntax user_dict['item_name'].
I think the UserDict object didn't exist in Python when I first wrote this
lib. Not sure though. If UserDict isn't supported in py3.6, then I'm not
sure this change is worth it? 🤔
…On Wed, Jan 19, 2022, 13:35 jupiterbjy ***@***.***> wrote:
Just looked up implementation of _dict, have any plan to use
collections.UserDict
<https://docs.python.org/3.7/library/collections.html#collections.UserDict>
instead? As far as I know subclassing of built-in types like dict, list
etc in CPython is not recommended, hence there's built-in alternatives for
Dict that are designed to be subclassed without hassle.
—
Reply to this email directly, view it on GitHub
<#16 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGPFI5J77VDSHLA63BAQXTTUW2OXJANCNFSM4KF2AKOQ>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
Well... Seems like best bet is to add Type Annotation and keeping type hint in docstring at same time, as definition part get dirty really quickly. Above result is from code change of following: class Aiogoogle:
# ...
"""
Arguments:
session_factory (aiogoogle.sessions.abc.AbstractSession): AbstractSession Implementation. Defaults to ``aiogoogle.sessions.aiohttp_session.AiohttpSession``
api_key (aiogoogle.auth.creds.ApiKey | str): Google API key
user_creds (aiogoogle.auth.creds.UserCreds | Mapping): OAuth2 cser credentials
client_creds (aiogoogle.auth.creds.ClientCreds | Mapping): OAuth2 client credentials
service_account_creds (aiogoogle.auth.creds.ServiceAccountCreds | Mapping): Service account credentials
"""
def __init__(
self,
session_factory: Type[AbstractSession] = AiohttpSession,
api_key: Union[ApiKey, str] = None,
user_creds: Union[UserCreds, Mapping] = None,
client_creds: Union[ClientCreds, Mapping] = None,
service_account_creds: Union[ServiceAccountCreds, Mapping] = None,
): And this do fix false warning when passing I'm not sure if cleaner alternative is possible, considering other projects that's using readthedocs.org are also having very complex-looking argument page - They decided to keep both type hints on type annotation and docstring. So yeah, I'll say it's totally possible to make it backward-compatible but also I'm no expert! I'm leaving final decision up to you! |
Actually I thought about it again and reached conclusion "Why fix when there's no issue?" - So I removed that comment.
As far as I know it was added on Python 3.7, depending on when you created this repository it might not existed! |
The changes you made to the Aiogoogle class look very good to me. I think it's worth it to litter the blue part of the docs if it gives us better typing in IDEs. Most people will be looking at the parameters section anyways. |
Let's stick with supporting Py3.6 then.
Agreed |
Ah wasn't it targeting 3.7? Somehow aiogoogle on pypi is reporting 3.7 |
Pypi is missing some targets it seems. In the test suite (Tox) and Github Actions we're testing for 3.6. e.g. here https://github.com/omarryhan/aiogoogle/blob/master/.github/workflows/action.yml#L56 and here: https://github.com/omarryhan/aiogoogle/blob/master/tox.ini#L2 |
I checked and it was I who was being dumb; changes I mentioned are totally unnecessary, it was me who was feeding wrong |
Totally okay! :)
… On 21 Jan 2022, at 12:42 PM, jupiterbjy ***@***.***> wrote:
I checked and it was I who was being dumb; changes I mentioned are totally unnecessary, it was me who was feeding wrong dict structure (Feeding string to scope, not list) to Aiogoogle, sorry!
—
Reply to this email directly, view it on GitHub <#16 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AGPFI5IKZEOAKX7GXUZB5JTUXE2CPANCNFSM4KF2AKOQ>.
You are receiving this because you modified the open/close state.
|
No description provided.
The text was updated successfully, but these errors were encountered: