11from traitlets import Instance , Type
22from traitlets .config import LoggingConfigurable
3- from typing import Any
3+ from typing import Any , Optional
44
55
66class BaseAuthPlugin (LoggingConfigurable ):
77
8- def get_student_courses (self , student_id ) : # pragma: no cover
8+ def get_student_courses (self , student_id : str ) -> Optional [ list ] : # pragma: no cover
99 """Gets the list of courses that the student is enrolled in.
1010
1111 Arguments
@@ -23,7 +23,7 @@ def get_student_courses(self, student_id): # pragma: no cover
2323 """
2424 raise NotImplementedError
2525
26- def add_student_to_course (self , student_id , course_id ) : # pragma: no cover
26+ def add_student_to_course (self , student_id : str , course_id : str ) -> None : # pragma: no cover
2727 """Grants a student access to a given course.
2828
2929 Arguments
@@ -36,7 +36,7 @@ def add_student_to_course(self, student_id, course_id): # pragma: no cover
3636 """
3737 raise NotImplementedError
3838
39- def remove_student_from_course (self , student_id , course_id ) : # pragma: no cover
39+ def remove_student_from_course (self , student_id : str , course_id : str ) -> None : # pragma: no cover
4040 """Removes a student's access to a given course.
4141
4242 Arguments
@@ -52,17 +52,17 @@ def remove_student_from_course(self, student_id, course_id): # pragma: no cover
5252
5353class NoAuthPlugin (BaseAuthPlugin ):
5454
55- def get_student_courses (self , student_id ) :
55+ def get_student_courses (self , student_id : str ) -> Optional [ list ] :
5656 # None means that the student has access to any course that might exist
5757 # on the system.
5858 return None
5959
60- def add_student_to_course (self , student_id , course_id ) :
60+ def add_student_to_course (self , student_id : str , course_id : str ) -> None :
6161 # Nothing to do, we don't keep track of which students are in which
6262 # courses in the default setting.
6363 pass
6464
65- def remove_student_from_course (self , student_id , course_id ) :
65+ def remove_student_from_course (self , student_id : str , course_id : str ) -> None :
6666 # Nothing to do, we don't keep track of which students are in which
6767 # courses in the default setting.
6868 pass
@@ -83,7 +83,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
8383 self .log .debug ("Using authenticator: %s" , self .plugin_class .__name__ )
8484 self .plugin = self .plugin_class (parent = self )
8585
86- def get_student_courses (self , student_id ) :
86+ def get_student_courses (self , student_id : str ) -> Optional [ list ] :
8787 """Gets the list of courses that the student is enrolled in.
8888
8989 Arguments
@@ -101,7 +101,7 @@ def get_student_courses(self, student_id):
101101 """
102102 return self .plugin .get_student_courses (student_id )
103103
104- def has_access (self , student_id , course_id ) :
104+ def has_access (self , student_id : str , course_id : str ) -> bool :
105105 """Checks whether a student has access to a particular course.
106106
107107 Arguments
@@ -121,7 +121,7 @@ def has_access(self, student_id, course_id):
121121 return True
122122 return course_id in courses
123123
124- def add_student_to_course (self , student_id : str , course_id : str ) -> Any :
124+ def add_student_to_course (self , student_id : str , course_id : str ) -> None :
125125 """Grants a student access to a given course.
126126
127127 Arguments
@@ -132,9 +132,9 @@ def add_student_to_course(self, student_id: str, course_id: str) -> Any:
132132 The unique id of the course.
133133
134134 """
135- return self .plugin .add_student_to_course (student_id , course_id )
135+ self .plugin .add_student_to_course (student_id , course_id )
136136
137- def remove_student_from_course (self , student_id , course_id ) :
137+ def remove_student_from_course (self , student_id : str , course_id : str ) -> None :
138138 """Removes a student's access to a given course.
139139
140140 Arguments
0 commit comments