@@ -55,7 +55,7 @@ async def _init_profile(self):
5555 :return: None
5656 :raises: oracledb.DatabaseError
5757 """
58- if self .profile_name is not None :
58+ if self .profile_name :
5959 profile_exists = False
6060 try :
6161 saved_attributes = await self ._get_attributes (
@@ -75,7 +75,7 @@ async def _init_profile(self):
7575 profile_name = self .profile_name
7676 )
7777 except ProfileNotFoundError :
78- if self .attributes is None :
78+ if self .attributes is None and self . description is None :
7979 raise
8080 else :
8181 if self .attributes is None :
@@ -91,10 +91,13 @@ async def _init_profile(self):
9191 await self .create (
9292 replace = self .replace , description = self .description
9393 )
94+ else : # profile name is None:
95+ if self .attributes is not None or self .description is not None :
96+ raise ValueError ("'profile_name' cannot be empty or None" )
9497 return self
9598
9699 @staticmethod
97- async def _get_profile_description (profile_name ) -> str :
100+ async def _get_profile_description (profile_name ) -> Union [ str , None ] :
98101 """Get description of profile from USER_CLOUD_AI_PROFILES
99102
100103 :param str profile_name: Name of profile
@@ -110,7 +113,10 @@ async def _get_profile_description(profile_name) -> str:
110113 )
111114 profile = await cr .fetchone ()
112115 if profile :
113- return await profile [1 ].read ()
116+ if profile [1 ] is not None :
117+ return await profile [1 ].read ()
118+ else :
119+ return None
114120 else :
115121 raise ProfileNotFoundError (profile_name )
116122
@@ -186,6 +192,12 @@ async def set_attributes(self, attributes: ProfileAttributes):
186192 attributes
187193 :return: None
188194 """
195+ if not isinstance (attributes , ProfileAttributes ):
196+ raise TypeError (
197+ "'attributes' must be an object of type "
198+ "select_ai.ProfileAttributes"
199+ )
200+
189201 self .attributes = attributes
190202 parameters = {
191203 "profile_name" : self .profile_name ,
0 commit comments