Comments (11)
aiogoogle/examples/auth/oauth2.py
Lines 28 to 41 in 4eef158
I can see Aiogoogle.client_creds
was meant to accept the dict
.
However, in docstring:
Lines 30 to 36 in 4eef158
Which then makes linter to give false warning like below:
Previously I thought adding Union[]
on docstring would be enough, turns out PEP-484 actually does not mention anything about use of typing.Union
inside docsting, and therefore not properly supported by IDEs.
So only viable option would be making proper annotations, I'll try to make PL if I manage to annotate it later on.
from aiogoogle.
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!
from aiogoogle.
from aiogoogle.
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 dict
.
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!
from aiogoogle.
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'].
Actually I thought about it again and reached conclusion "Why fix when there's no issue?" - So I removed that comment.
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? 🤔
As far as I know it was added on Python 3.7, depending on when you created this repository it might not existed!
from aiogoogle.
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.
from aiogoogle.
As far as I know it was added on Python 3.7, depending on when you created this repository it might not existed!
Let's stick with supporting Py3.6 then.
"Why fix when there's no issue?"
Agreed
from aiogoogle.
Ah wasn't it targeting 3.7? Somehow aiogoogle on pypi is reporting 3.7
from aiogoogle.
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
from aiogoogle.
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!
from aiogoogle.
from aiogoogle.
Related Issues (20)
- Ability to upload from AsyncIterable object HOT 6
- Can we provide a way to test the package end to end? HOT 1
- URL formatting issue HOT 3
- URL encoding issues with Calendar IDs HOT 1
- Aiogoogle doesn't support the beta Drive Labels API HOT 5
- Token is not getting refreshed after its expired after around 1 hour HOT 17
- Inconsistent response. HOT 5
- Unclosed client session HOT 4
- URL formatting breaks the people.connections.list method HOT 1
- Updating google drive file contents yields corrupted file due to multipart HOT 5
- Authentication using application default method HOT 1
- HttpError doesn't include JSON error response with the "pipe_to" option enabled HOT 1
- paginn issue HOT 2
- Requesting Google Drive list with multiple pages always results in user_creds of None HOT 3
- Issue with `ServiceAccountCreds` with `universe_domain` HOT 2
- FYI sending messages with Gmail doesn't work HOT 1
- UserCreds oauth token not refreshed after 1hour HOT 1
- `trio` support broken: unexpected keyword argument 'auth_manager' HOT 3
- Using pipe_to and pipe_from HOT 13
- Module import error : contextvars HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aiogoogle.