Skip to content

Commit 6e94965

Browse files
committed
Convert to ruff formatting
1 parent 7cb6e63 commit 6e94965

1,372 files changed

Lines changed: 3517 additions & 6233 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/auth/gcc_high.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
Connect via national clouds (Microsoft 365 GCC High environment)
1+
"""Connect via national clouds (Microsoft 365 GCC High environment)
32
43
Microsoft Graph for US Government L4: https://graph.microsoft.us
54
"""

examples/auth/interactive.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
Demonstrates how to login when the user may be prompted for input by the authorization server.
1+
"""Demonstrates how to login when the user may be prompted for input by the authorization server.
32
For example, to sign in, perform multi-factor authentication (MFA), or to grant consent
43
to more resource access permissions.
54
@@ -9,13 +8,14 @@
98
109
https://learn.microsoft.com/en-us/azure/active-directory/develop/
1110
msal-authentication-flows#interactive-and-non-interactive-authentication
11+
1212
"""
1313

1414
from office365.graph_client import GraphClient
1515
from tests import test_client_id, test_tenant
1616

1717
client = GraphClient(tenant=test_tenant).with_token_interactive(test_client_id)
1818
me = client.me.get().execute_query()
19-
print("Welcome, {0}!".format(me.given_name))
19+
print(f"Welcome, {me.given_name}!")
2020
site = client.sites.root.get().execute_query()
21-
print("Site Url: {0}".format(site.web_url))
21+
print(f"Site Url: {site.web_url}")

examples/auth/interactive_custom.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
Demonstrates how to login when the user may be prompted for input by the authorization server.
1+
"""Demonstrates how to login when the user may be prompted for input by the authorization server.
32
For example, to sign in, perform multi-factor authentication (MFA), or to grant consent
43
to more resource access permissions.
54
@@ -9,6 +8,7 @@
98
109
https://learn.microsoft.com/en-us/azure/active-directory/develop/msal-authentication-flows
1110
#interactive-and-non-interactive-authentication
11+
1212
"""
1313

1414
import msal
@@ -20,7 +20,7 @@
2020
def acquire_token():
2121
app = msal.PublicClientApplication(
2222
test_client_id,
23-
authority="https://login.microsoftonline.com/{0}".format(test_tenant),
23+
authority=f"https://login.microsoftonline.com/{test_tenant}",
2424
client_credential=None,
2525
)
2626
scopes = ["https://graph.microsoft.com/.default"]

examples/auth/sharepoint/interactive.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
Demonstrates how to login when the user may be prompted for input by the authorization server.
1+
"""Demonstrates how to login when the user may be prompted for input by the authorization server.
32
For example, to sign in, perform multi-factor authentication (MFA), or to grant consent
43
to more resource access permissions.
54

examples/auth/sharepoint/interactive_custom.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
Demonstrates how to login when the user may be prompted for input by the authorization server.
1+
"""Demonstrates how to login when the user may be prompted for input by the authorization server.
32
For example, to sign in, perform multi-factor authentication (MFA), or to grant consent
43
to more resource access permissions.
54
@@ -19,10 +18,10 @@
1918
def acquire_token():
2019
app = msal.PublicClientApplication(
2120
test_client_id,
22-
authority="https://login.microsoftonline.com/{0}".format(test_tenant),
21+
authority=f"https://login.microsoftonline.com/{test_tenant}",
2322
client_credential=None,
2423
)
25-
scopes = ["https://{0}.sharepoint.com/.default".format(test_tenant_name)]
24+
scopes = [f"https://{test_tenant_name}.sharepoint.com/.default"]
2625
result = app.acquire_token_interactive(scopes=scopes)
2726
return TokenResponse.from_json(result)
2827

examples/auth/sharepoint/register_apponly.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
Setting up an Azure AD app for app-only access for SharePoint API
1+
"""Setting up an Azure AD app for app-only access for SharePoint API
32
43
Steps:
54

examples/auth/with_adal.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
Demonstrates how to acquire access token via ADAL library
1+
"""Demonstrates how to acquire access token via ADAL library
32
43
Note: ADAL for Python is no longer receive new feature improvement. Its successor, MSAL for Python,
54
are now generally available.
@@ -12,7 +11,7 @@
1211
def acquire_token():
1312
import adal # pylint: disable=E0401
1413

15-
authority_url = "https://login.microsoftonline.com/{0}".format(test_tenant_name)
14+
authority_url = f"https://login.microsoftonline.com/{test_tenant_name}"
1615
auth_ctx = adal.AuthenticationContext(authority_url)
1716
token = auth_ctx.acquire_token_with_username_password(
1817
"https://graph.microsoft.com",

examples/auth/with_client_cert.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
Demonstrates how to acquire a token by using certificate credentials.
1+
"""Demonstrates how to acquire a token by using certificate credentials.
32
43
https://learn.microsoft.com/en-us/azure/active-directory/develop/msal-authentication-flows#certificates
54
"""
@@ -9,10 +8,10 @@
98

109

1110
def acquire_token():
12-
with open(test_cert_path, "r", encoding="utf-8") as f:
11+
with open(test_cert_path, encoding="utf-8") as f:
1312
private_key = f.read()
1413

15-
authority_url = "https://login.microsoftonline.com/{0}".format(test_tenant_name)
14+
authority_url = f"https://login.microsoftonline.com/{test_tenant_name}"
1615
credentials = {"thumbprint": test_cert_thumbprint, "private_key": private_key}
1716
import msal
1817

examples/auth/with_client_secret.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
Acquires a token by using application secret
1+
"""Acquires a token by using application secret
32
43
The following options are supported:
54
- utilize built in GraphClient(tenant=tenant).with_client_secret(client_id, client_secret) method

examples/auth/with_client_secret_custom.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
Acquires a token by using application secret
1+
"""Acquires a token by using application secret
32
43
The following options are supported:
54
- utilize built in GraphClient(tenant=tenant).with_client_secret(client_id, client_secret) method
@@ -15,7 +14,7 @@
1514

1615

1716
def acquire_token():
18-
authority_url = "https://login.microsoftonline.com/{0}".format(test_tenant)
17+
authority_url = f"https://login.microsoftonline.com/{test_tenant}"
1918
app = msal.ConfidentialClientApplication(
2019
authority=authority_url,
2120
client_id=test_client_id,

0 commit comments

Comments
 (0)