Skip to content

Commit a56bc5e

Browse files
committed
examples section linter fixes
1 parent 1a169ab commit a56bc5e

19 files changed

+28
-25
lines changed

examples/__init__.py

Whitespace-only changes.

examples/auth/__init__.py

Whitespace-only changes.

examples/auth/interactive.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
in AAD portal ensure Mobile and Desktop application is added for application
88
and http://localhost is set as redirect uri
99
10-
https://learn.microsoft.com/en-us/azure/active-directory/develop/msal-authentication-flows#interactive-and-non-interactive-authentication
10+
https://learn.microsoft.com/en-us/azure/active-directory/develop/
11+
msal-authentication-flows#interactive-and-non-interactive-authentication
1112
"""
1213

1314
from office365.graph_client import GraphClient

examples/auth/interactive_custom.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
in AAD portal ensure Mobile and Desktop application is added for application
88
and http://localhost is set as redirect uri
99
10-
https://learn.microsoft.com/en-us/azure/active-directory/develop/msal-authentication-flows#interactive-and-non-interactive-authentication
10+
https://learn.microsoft.com/en-us/azure/active-directory/develop/msal-authentication-flows
11+
#interactive-and-non-interactive-authentication
1112
"""
1213

1314
import msal

examples/auth/with_adal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
def acquire_token():
13-
import adal
13+
import adal # pylint: disable=E0401
1414

1515
settings = load_settings()
1616
authority_url = "https://login.microsoftonline.com/{0}".format(

examples/auth/with_client_cert.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010

1111
def acquire_token():
12-
with open(test_cert_path, "r"):
13-
private_key = open(test_cert_path).read()
12+
with open(test_cert_path, "r", encoding="utf-8") as f:
13+
private_key = f.read()
1414

1515
authority_url = "https://login.microsoftonline.com/{0}".format(test_tenant_name)
1616
credentials = {"thumbprint": test_cert_thumbprint, "private_key": private_key}

examples/onedrive/__init__.py

Whitespace-only changes.

examples/sharepoint/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/sharepoint/auth_app_principal_aad.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
using Client Credentials flow (app-only access) will return 401 error, meaning this flow is NOT supported (blocked)
88
unless:
99
10-
- AAD app is explicitly granted access via ACS as explained here: https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs
11-
- Client Certificate flow is utilized instead as explained here https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azuread
10+
- AAD app is explicitly granted access via ACS as explained here:
11+
https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs
12+
- Client Certificate flow is utilized instead as explained here:
13+
https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azuread
1214
1315
1416

examples/sharepoint/auth_certificate.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azuread
1010
1111
Refer wiki for a more details:
12-
https://github.com/vgrem/Office365-REST-Python-Client/wiki/How-to-connect-to-SharePoint-Online-with-certificate-credentials
12+
https://github.com/vgrem/Office365-REST-Python-Client/wiki/
13+
How-to-connect-to-SharePoint-Online-with-certificate-credentials
1314
"""
1415

1516
from office365.sharepoint.client_context import ClientContext

examples/sharepoint/auth_certificate_adal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def acquire_token():
1616

1717
authority_url = "https://login.microsoftonline.com/{0}".format(test_tenant)
1818
auth_ctx = adal.AuthenticationContext(authority_url)
19-
with open(cert_settings["certificate_path"], "r") as file:
19+
with open(cert_settings["certificate_path"], "r", encoding="utf-8") as file:
2020
key = file.read()
2121
json_token = auth_ctx.acquire_token_with_client_certificate(
2222
test_site_url, cert_settings["client_id"], key, cert_settings["thumbprint"]

examples/sharepoint/auth_certificate_passphrase.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azuread
1010
1111
Refer wiki for a more details:
12-
https://github.com/vgrem/Office365-REST-Python-Client/wiki/How-to-connect-to-SharePoint-Online-with-certificate-credentials
12+
https://github.com/vgrem/Office365-REST-Python-Client/wiki/
13+
How-to-connect-to-SharePoint-Online-with-certificate-credentials
1314
1415
To create a self signed certificate with encrypted private key run:
1516
openssl req -x509 -newkey rsa:2048 -keyout selfsignkey.pem -out selfsigncert.pem -days 365

examples/sharepoint/auth_certificate_private_key.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@
1616
https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azuread
1717
"""
1818

19-
import os
20-
2119
from office365.sharepoint.client_context import ClientContext
2220
from tests import test_cert_thumbprint, test_client_id, test_site_url, test_tenant
2321

24-
cert_path = "{0}/../selfsignkey.pem".format(os.path.dirname(__file__))
25-
with open(cert_path, "r") as f:
26-
private_key = open(cert_path).read()
22+
cert_path = "./selfsigncert.pem"
23+
with open(cert_path, "r", encoding="utf-8") as f:
24+
private_key = f.read()
2725

2826
cert_credentials = {
2927
"tenant": test_tenant,

examples/sharepoint/auth_interactive.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
Prerequisite: In Azure Portal, configure the Redirect URI of your
77
"Mobile and Desktop application" as ``http://localhost``.
88
9-
https://learn.microsoft.com/en-us/azure/active-directory/develop/msal-authentication-flows#interactive-and-non-interactive-authentication
9+
https://learn.microsoft.com/en-us/azure/active-directory/develop/
10+
msal-authentication-flows#interactive-and-non-interactive-authentication
1011
"""
1112

1213
from office365.sharepoint.client_context import ClientContext

examples/sharepoint/run_test_perf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
that the request took on the server to be processed. This can help determine if the request is heavy and resource
77
intensive.
88
9-
https://learn.microsoft.com/en-us/microsoft-365/enterprise/diagnosing-performance-issues-with-sharepoint-online?view=o365-worldwide
9+
https://learn.microsoft.com/en-us/microsoft-365/enterprise/
10+
diagnosing-performance-issues-with-sharepoint-online?view=o365-worldwide
1011
"""
1112

1213
from requests import Response

examples/sharepoint/views/export_items.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def export_to_csv(path, list_items):
1111
:param str path: export path
1212
:param office365.sharepoint.listitems.collection.ListItemCollection list_items: List items
1313
"""
14-
with open(path, "w") as fh:
14+
with open(path, "w", encoding="utf-8") as fh:
1515
fields = list_items[0].properties.keys()
1616
w = csv.DictWriter(fh, fields)
1717
w.writeheader()

generator/builders/type_builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ def build(self):
3030
self._status = "updated"
3131
else:
3232
template_file = self._resolve_template_file(self._schema.baseType)
33-
with open(template_file) as f:
33+
with open(template_file, encoding="utf-8") as f:
3434
self._source_tree = ast.parse(f.read())
3535
self._status = "created"
3636
self.visit(self._source_tree)
3737
return self
3838

3939
def save(self):
4040
code = astunparse.unparse(self._source_tree)
41-
with open(self.file, "w") as f:
41+
with open(self.file, "w", encoding="utf-8") as f:
4242
f.write(code)
4343

4444
def _resolve_template_file(self, type_name):

office365/directory/users/user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def send_mail(
272272
to_recipients,
273273
cc_recipients=None,
274274
bcc_recipients=None,
275-
reply_to = None,
275+
reply_to=None,
276276
save_to_sent_items=False,
277277
body_type="Text",
278278
):

office365/outlook/mail/messages/message.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,7 @@ def cc_recipients(self):
422422
def reply_to(self):
423423
"""The replyTo: recipients for the reply to the message."""
424424
self._persist_changes("replyTo")
425-
return self.properties.setdefault(
426-
"replyTo", ClientValueCollection(Recipient)
427-
)
425+
return self.properties.setdefault("replyTo", ClientValueCollection(Recipient))
428426

429427
@property
430428
def sender(self):

0 commit comments

Comments
 (0)