@@ -91,13 +91,17 @@ def update(self):
9191 if pfx in script .text :
9292 educator_username = commons .webscrape_count (script .text , pfx , sfx , str )
9393
94- ret = {"id" : self .id ,
95- "title" : title ,
96- "description" : description ,
97- "status" : status ,
98- "educator" : {"username" : educator_username },
99- "is_closed" : True
100- }
94+ ret : typed_dicts .ClassroomDict = {
95+ "id" : self .id ,
96+ "title" : title ,
97+ "description" : description ,
98+ "educator" : {},
99+ "status" : status ,
100+ "is_closed" : True
101+ }
102+
103+ if educator_username :
104+ ret ["educator" ]["username" ] = educator_username
101105
102106 return self ._update_from_dict (ret )
103107 return success
@@ -136,7 +140,7 @@ def student_names(self, *, page=1) -> list[str]:
136140 response = requests .get (f"https://scratch.mit.edu/classes/{ self .id } /" )
137141 soup = BeautifulSoup (response .text , "html.parser" )
138142 found = set ("" )
139-
143+
140144 for result in soup .css .select ("ul.scroll-content .user a" ):
141145 result_text = result .text .strip ()
142146 if result_text in found :
@@ -185,7 +189,7 @@ def class_studio_ids(self, *, page: int = 1) -> list[int]:
185189 ret = []
186190 response = requests .get (f"https://scratch.mit.edu/classes/{ self .id } /" )
187191 soup = BeautifulSoup (response .text , "html.parser" )
188-
192+
189193 for result in soup .css .select ("ul.scroll-content .gallery a[href]:not([class])" ):
190194 value = result ["href" ]
191195 if not isinstance (value , str ):
@@ -392,7 +396,13 @@ def get_classroom(class_id: str) -> Classroom:
392396
393397 If you want to use these, get the user with :meth:`scratchattach.session.Session.connect_classroom` instead.
394398 """
395- warnings .warn ("For methods that require authentication, use session.connect_classroom instead of get_classroom" )
399+ warnings .warn (
400+ "For methods that require authentication, use session.connect_classroom instead of get_classroom\n "
401+ "If you want to remove this warning, use warnings.filterwarnings('ignore', category=scratchattach.ClassroomAuthenticationWarning)\n "
402+ "To ignore all warnings of the type GetAuthenticationWarning, which includes this warning, use "
403+ "`warnings.filterwarnings('ignore', category=scratchattach.GetAuthenticationWarning)`." ,
404+ exceptions .ClassroomAuthenticationWarning
405+ )
396406 return commons ._get_object ("id" , class_id , Classroom , exceptions .ClassroomNotFound )
397407
398408
@@ -411,7 +421,13 @@ def get_classroom_from_token(class_token) -> Classroom:
411421
412422 If you want to use these, get the user with :meth:`scratchattach.session.Session.connect_classroom` instead.
413423 """
414- warnings .warn ("For methods that require authentication, use session.connect_classroom instead of get_classroom" )
424+ warnings .warn (
425+ "For methods that require authentication, use session.connect_classroom instead of get_classroom. "
426+ "If you want to remove this warning, use warnings.filterwarnings('ignore', category=ClassroomAuthenticationWarning). "
427+ "To ignore all warnings of the type GetAuthenticationWarning, which includes this warning, use "
428+ "warnings.filterwarnings('ignore', category=GetAuthenticationWarning)." ,
429+ exceptions .ClassroomAuthenticationWarning
430+ )
415431 return commons ._get_object ("classtoken" , class_token , Classroom , exceptions .ClassroomNotFound )
416432
417433
0 commit comments