Skip to content

Commit df23ea4

Browse files
committed
Changed code to account for breaking change in SDK
1 parent dc91de1 commit df23ea4

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

user-auth/graphtutorial/graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ async def get_inbox(self):
7272
query_parameters= query_params
7373
)
7474

75-
messages = await self.user_client.me.mail_folders_by_id('inbox').messages.get(
75+
messages = await self.user_client.me.mail_folders.by_mail_folder_id('inbox').messages.get(
7676
request_configuration=request_config)
7777
return messages
7878
# </GetInboxSnippet>

user-auth/graphtutorial/main.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# <ProgramSnippet>
55
import asyncio
66
import configparser
7-
from graph import Graph
87
from msgraph.generated.models.o_data_errors.o_data_error import ODataError
8+
from graph import Graph
99

1010
async def main():
1111
print('Python Graph Tutorial\n')
@@ -47,16 +47,16 @@ async def main():
4747
await make_graph_call(graph)
4848
else:
4949
print('Invalid choice!\n')
50-
except ODataError as e:
50+
except ODataError as odata_error:
5151
print('Error:')
52-
if e.error is not None:
53-
print(e.error.code, e.error.message)
52+
if odata_error.error:
53+
print(odata_error.error.code, odata_error.error.message)
5454
# </ProgramSnippet>
5555

5656
# <GreetUserSnippet>
5757
async def greet_user(graph: Graph):
5858
user = await graph.get_user()
59-
if user is not None:
59+
if user:
6060
print('Hello,', user.display_name)
6161
# For Work/school accounts, email is in mail property
6262
# Personal accounts, email is in userPrincipalName
@@ -72,13 +72,13 @@ async def display_access_token(graph: Graph):
7272
# <ListInboxSnippet>
7373
async def list_inbox(graph: Graph):
7474
message_page = await graph.get_inbox()
75-
if message_page is not None and message_page.value is not None:
75+
if message_page and message_page.value:
7676
# Output each message's details
7777
for message in message_page.value:
7878
print('Message:', message.subject)
7979
if (
80-
message.from_ is not None and
81-
message.from_.email_address is not None
80+
message.from_ and
81+
message.from_.email_address
8282
):
8383
print(' From:', message.from_.email_address.name or 'NONE')
8484
else:
@@ -96,7 +96,7 @@ async def send_mail(graph: Graph):
9696
# Send mail to the signed-in user
9797
# Get the user for their email address
9898
user = await graph.get_user()
99-
if user is not None:
99+
if user:
100100
user_email = user.mail or user.user_principal_name
101101

102102
await graph.send_mail('Testing Microsoft Graph', 'Hello world!', user_email or '')

user-auth/graphtutorial/pylintrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,5 +576,5 @@ preferred-modules=
576576

577577
# Exceptions that will emit a warning when being caught. Defaults to
578578
# "BaseException, Exception".
579-
overgeneral-exceptions=BaseException,
580-
Exception
579+
overgeneral-exceptions=builtins.BaseException,
580+
builtins.Exception

0 commit comments

Comments
 (0)