Skip to content

Commit a032472

Browse files
committed
linting
1 parent 87edd11 commit a032472

File tree

11 files changed

+91
-106
lines changed

11 files changed

+91
-106
lines changed

.vscode/settings.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{
22
"python.linting.enabled": true,
3-
// "python.linting.pylintEnabled": true
3+
"python.linting.pylintEnabled": false,
4+
"python.pythonPath": "C:\\Users\\Alex\\AppData\\Local\\Programs\\Python\\Python39\\python.exe",
5+
"python.linting.flake8Enabled": true,
6+
"python.linting.flake8Args": [
7+
"--max-line-length=120",
8+
"--ignore=E402",
9+
],
410
}

ms_graph/client.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
import json
22
import msal
33
import time
4-
import pprint
54
import urllib
6-
import requests
75
import random
86
import string
97
import pathlib
108

119
from typing import List
1210
from typing import Dict
13-
from typing import Union
1411

1512
from ms_graph.users import Users
1613
from ms_graph.drives import Drives
@@ -19,8 +16,6 @@
1916
from ms_graph.session import GraphSession
2017
from ms_graph.drive_items import DriveItems
2118

22-
from urllib.parse import urlencode, urlparse, quote_plus
23-
2419

2520
class MicrosoftGraphClient():
2621

@@ -34,23 +29,28 @@ class MicrosoftGraphClient():
3429
OFFICE365_AUTH_ENDPOINT = '/oauth20_authorize.srf?'
3530
OFFICE365_TOKEN_ENDPOINT = '/oauth20_token.srf'
3631

37-
def __init__(self, client_id: str, client_secret: str, redirect_uri: str, scope: List[str],
38-
account_type: str = 'consumers', office365: bool = False, credentials: str = None):
32+
def __init__(self, client_id: str, client_secret: str, redirect_uri: str,
33+
scope: List[str], account_type: str = 'consumers',
34+
office365: bool = False, credentials: str = None):
3935
"""Initializes the Graph Client.
4036
4137
### Parameters
4238
----
4339
client_id : str
44-
The application Client ID assigned when creating a new Microsoft App.
40+
The application Client ID assigned when
41+
creating a new Microsoft App.
4542
4643
client_secret : str
47-
The application Client Secret assigned when creating a new Microsoft App.
44+
The application Client Secret assigned when
45+
creating a new Microsoft App.
4846
4947
redirect_uri : str
50-
The application Redirect URI assigned when creating a new Microsoft App.
48+
The application Redirect URI assigned when
49+
creating a new Microsoft App.
5150
5251
scope : List[str]
53-
The list of scopes you want the application to have access to.
52+
The list of scopes you want the application
53+
to have access to.
5454
5555
account_type : str, optional
5656
[description], by default 'common'
@@ -137,8 +137,10 @@ def _state(self, action: str, token_dict: dict = None) -> bool:
137137
# If we are saving the state then open the file and dump the dictionary.
138138
elif action == 'save':
139139

140-
token_dict['expires_in'] = time.time() + int(token_dict['expires_in'])
141-
token_dict['ext_expires_in'] = time.time() + int(token_dict['ext_expires_in'])
140+
token_dict['expires_in'] = time.time(
141+
) + int(token_dict['expires_in'])
142+
token_dict['ext_expires_in'] = time.time(
143+
) + int(token_dict['ext_expires_in'])
142144

143145
self.refresh_token = token_dict['refresh_token']
144146
self.access_token = token_dict['access_token']
@@ -157,7 +159,7 @@ def _token_seconds(self, token_type: str = 'access_token') -> int:
157159
158160
### Arguments:
159161
----
160-
token_type {str} -- The type of token you would like to determine lifespan for.
162+
token_type {str} -- The type of token you would like to determine lifespan for.
161163
Possible values are ['access_token', 'refresh_token'] (default: {access_token})
162164
163165
### Returns:
@@ -198,7 +200,7 @@ def _token_validation(self, nseconds: int = 60):
198200
199201
Arguments:
200202
----
201-
nseconds {int} -- The minimum number of seconds the token has to be
203+
nseconds {int} -- The minimum number of seconds the token has to be
202204
valid for before attempting to get a refresh token. (default: {5})
203205
"""
204206

@@ -396,4 +398,4 @@ def notes(self) -> Notes:
396398
# Grab the `Notes` Object for the session.
397399
notes_object: Notes = Notes(session=self.graph_session)
398400

399-
return notes_object
401+
return notes_object

ms_graph/drive_items.py

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
from typing import List
21
from typing import Dict
3-
from typing import Union
4-
52
from ms_graph.session import GraphSession
63

74

@@ -10,9 +7,9 @@ class DriveItems():
107
"""
118
## Overview:
129
----
13-
The driveItem resource represents a file, folder,
14-
or other item stored in a drive. All file system
15-
objects in OneDrive and SharePoint are returned as
10+
The driveItem resource represents a file, folder,
11+
or other item stored in a drive. All file system
12+
objects in OneDrive and SharePoint are returned as
1613
driveItem resources.
1714
"""
1815

@@ -32,8 +29,7 @@ def __init__(self, session: object) -> None:
3229
self.endpoint = 'drive'
3330
self.collections_endpoint = 'drives/'
3431

35-
36-
def get_drive_item(self, drive_id: str, item_id: str) -> Dict:
32+
def get_drive_item(self, drive_id: str, item_id: str) -> Dict:
3733
"""Grab's a DriveItem Resource using the Item ID and Drive ID.
3834
3935
### Parameters
@@ -53,15 +49,15 @@ def get_drive_item(self, drive_id: str, item_id: str) -> Dict:
5349

5450
content = self.graph_session.make_request(
5551
method='get',
56-
endpoint= self.collections_endpoint + "/{drive_id}/items/{item_id}".format(
52+
endpoint=self.collections_endpoint + "/{drive_id}/items/{item_id}".format(
5753
drive_id=drive_id,
5854
item_id=item_id
5955
)
6056
)
6157

6258
return content
6359

64-
def get_drive_item_by_path(self, drive_id: str, item_path: str) -> Dict:
60+
def get_drive_item_by_path(self, drive_id: str, item_path: str) -> Dict:
6561
"""Grab's a DriveItem Resource using the Item ID and Drive ID.
6662
6763
### Parameters
@@ -80,15 +76,15 @@ def get_drive_item_by_path(self, drive_id: str, item_path: str) -> Dict:
8076

8177
content = self.graph_session.make_request(
8278
method='get',
83-
endpoint= self.collections_endpoint + "/{drive_id}/root:/{path}".format(
79+
endpoint=self.collections_endpoint + "/{drive_id}/root:/{path}".format(
8480
drive_id=drive_id,
8581
path=item_path
8682
)
8783
)
8884

8985
return content
9086

91-
def get_group_drive_item(self, group_id: str, item_id: str) -> Dict:
87+
def get_group_drive_item(self, group_id: str, item_id: str) -> Dict:
9288
"""Grab's a DriveItem Resource using the Item ID and Drive ID.
9389
9490
### Parameters
@@ -108,15 +104,15 @@ def get_group_drive_item(self, group_id: str, item_id: str) -> Dict:
108104

109105
content = self.graph_session.make_request(
110106
method='get',
111-
endpoint= "/groups/{group_id}/drive/items/{item_id}".format(
107+
endpoint="/groups/{group_id}/drive/items/{item_id}".format(
112108
group_id=group_id,
113109
item_id=item_id
114110
)
115111
)
116112

117113
return content
118114

119-
def get_group_drive_item_by_path(self, group_id: str, item_path: str) -> Dict:
115+
def get_group_drive_item_by_path(self, group_id: str, item_path: str) -> Dict:
120116
"""Grab's a DriveItem Resource using the Item ID and Drive ID.
121117
122118
### Parameters
@@ -135,15 +131,15 @@ def get_group_drive_item_by_path(self, group_id: str, item_path: str) -> Dict:
135131

136132
content = self.graph_session.make_request(
137133
method='get',
138-
endpoint= "/groups/{group_id}/drive/root:/{item_path}".format(
134+
endpoint="/groups/{group_id}/drive/root:/{item_path}".format(
139135
group_id=group_id,
140136
item_path=item_path
141137
)
142138
)
143139

144140
return content
145141

146-
def get_my_drive_item(self, item_id: str) -> Dict:
142+
def get_my_drive_item(self, item_id: str) -> Dict:
147143
"""Grab's a DriveItem Resource using the Item ID and Drive ID.
148144
149145
### Parameters
@@ -160,14 +156,14 @@ def get_my_drive_item(self, item_id: str) -> Dict:
160156

161157
content = self.graph_session.make_request(
162158
method='get',
163-
endpoint= "/me/drive/items/{item_id}".format(
159+
endpoint="/me/drive/items/{item_id}".format(
164160
item_id=item_id
165161
)
166162
)
167163

168164
return content
169165

170-
def get_my_drive_item_by_path(self, item_path: str) -> Dict:
166+
def get_my_drive_item_by_path(self, item_path: str) -> Dict:
171167
"""Grab's a DriveItem Resource using the Item ID and Drive ID.
172168
173169
### Parameters
@@ -183,14 +179,14 @@ def get_my_drive_item_by_path(self, item_path: str) -> Dict:
183179

184180
content = self.graph_session.make_request(
185181
method='get',
186-
endpoint= "/me/drive/root:/{item_path}".format(
182+
endpoint="/me/drive/root:/{item_path}".format(
187183
item_path=item_path
188184
)
189185
)
190186

191187
return content
192188

193-
def get_site_drive_item(self, site_id: str, item_id: str) -> Dict:
189+
def get_site_drive_item(self, site_id: str, item_id: str) -> Dict:
194190
"""Grab's a DriveItem Resource using the Item ID and Drive ID.
195191
196192
### Parameters
@@ -210,15 +206,15 @@ def get_site_drive_item(self, site_id: str, item_id: str) -> Dict:
210206

211207
content = self.graph_session.make_request(
212208
method='get',
213-
endpoint= "/sites/{site_id}/drive/items/{item_id}".format(
209+
endpoint="/sites/{site_id}/drive/items/{item_id}".format(
214210
site_id=site_id,
215211
item_id=item_id
216212
)
217213
)
218214

219215
return content
220216

221-
def get_site_drive_item_by_path(self, site_id: str, item_path: str) -> Dict:
217+
def get_site_drive_item_by_path(self, site_id: str, item_path: str) -> Dict:
222218
"""Grab's a DriveItem Resource using the Item ID and Drive ID.
223219
224220
### Parameters
@@ -237,15 +233,15 @@ def get_site_drive_item_by_path(self, site_id: str, item_path: str) -> Dict:
237233

238234
content = self.graph_session.make_request(
239235
method='get',
240-
endpoint= "/sites/{site_id}/drive/root:/{item_path}".format(
236+
endpoint="/sites/{site_id}/drive/root:/{item_path}".format(
241237
site_id=site_id,
242238
item_path=item_path
243239
)
244240
)
245241

246242
return content
247243

248-
def get_site_drive_item_from_list(self, site_id: str, list_id: str, item_id: str) -> Dict:
244+
def get_site_drive_item_from_list(self, site_id: str, list_id: str, item_id: str) -> Dict:
249245
"""Grab's a DriveItem Resource using the Item ID and Drive ID.
250246
251247
### Parameters
@@ -268,7 +264,7 @@ def get_site_drive_item_from_list(self, site_id: str, list_id: str, item_id: str
268264

269265
content = self.graph_session.make_request(
270266
method='get',
271-
endpoint= "/sites/{site_id}/lists/{list_id}/items/{item_id}/driveItem".format(
267+
endpoint="/sites/{site_id}/lists/{list_id}/items/{item_id}/driveItem".format(
272268
site_id=site_id,
273269
list_id=list_id,
274270
item_id=item_id
@@ -277,7 +273,7 @@ def get_site_drive_item_from_list(self, site_id: str, list_id: str, item_id: str
277273

278274
return content
279275

280-
def get_user_drive_item(self, user_id: str, item_id: str) -> Dict:
276+
def get_user_drive_item(self, user_id: str, item_id: str) -> Dict:
281277
"""Grab's a DriveItem Resource using the Item ID and Drive ID.
282278
283279
### Parameters
@@ -297,15 +293,15 @@ def get_user_drive_item(self, user_id: str, item_id: str) -> Dict:
297293

298294
content = self.graph_session.make_request(
299295
method='get',
300-
endpoint= "/users/{user_id}/drive/items/{item_id}".format(
296+
endpoint="/users/{user_id}/drive/items/{item_id}".format(
301297
user_id=user_id,
302298
item_id=item_id
303299
)
304300
)
305301

306302
return content
307303

308-
def get_user_drive_item_by_path(self, user_id: str, item_path: str) -> Dict:
304+
def get_user_drive_item_by_path(self, user_id: str, item_path: str) -> Dict:
309305
"""Grab's a DriveItem Resource using the Item ID and Drive ID.
310306
311307
### Parameters
@@ -324,7 +320,7 @@ def get_user_drive_item_by_path(self, user_id: str, item_path: str) -> Dict:
324320

325321
content = self.graph_session.make_request(
326322
method='get',
327-
endpoint= "/users/{user_id}/drive/root:/{item_path}".format(
323+
endpoint="/users/{user_id}/drive/root:/{item_path}".format(
328324
user_id=user_id,
329325
item_path=item_path
330326
)

ms_graph/drives.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
from typing import List
21
from typing import Dict
3-
from typing import Union
4-
52
from ms_graph.session import GraphSession
63

74

@@ -10,7 +7,7 @@ class Drives():
107
"""
118
## Overview:
129
----
13-
The drive resource is the top level object representing a user's OneDrive or a
10+
The drive resource is the top level object representing a user's OneDrive or a
1411
document library in SharePoint. OneDrive users will always have at least one drive
1512
available, their default drive. Users without a OneDrive license may not have a default
1613
drive available.
@@ -97,7 +94,7 @@ def get_root_drive_followed(self) -> Dict:
9794
return content
9895

9996
def get_recent_files(self) -> Dict:
100-
"""List a set of items that have been recently used by the signed in user.
97+
"""List a set of items that have been recently used by the signed in user.
10198
10299
### Overview:
103100
----
@@ -139,13 +136,13 @@ def get_special_folder_by_name(self, folder_name: str) -> Dict:
139136
### Overview:
140137
----
141138
Special folders provide simple aliases to access well-known folders
142-
in OneDrive without the need to look up the folder by path (which
139+
in OneDrive without the need to look up the folder by path (which
143140
would require localization), or reference the folder with an ID. If
144-
a special folder is renamed or moved to another location within the
141+
a special folder is renamed or moved to another location within the
145142
drive, this syntax will continue to find that folder. Special folders
146143
are automatically created the first time an application attempts to write
147144
to one, if it doesn't already exist. If a user deletes one, it is recreated
148-
when written to again. Note: If you have read-only permissions and request
145+
when written to again. Note: If you have read-only permissions and request
149146
a special folder that doesn't exist, you'll receive a 403 Forbidden error.
150147
151148
### Returns

0 commit comments

Comments
 (0)