1- from vrcpy ._hardtyping import *
2-
3- from vrcpy .errors import IntegretyError , GeneralError
4- from vrcpy import types
51
62import asyncio
73
4+ import vrcpy
5+ from vrcpy import types
6+ from vrcpy .errors import IntegretyError , GeneralError
7+ from vrcpy ._hardtyping import *
8+
89
910class BaseObject :
1011 objType = "Base"
1112
1213 def __init__ (self , client ):
14+ self .id = None
1315 self .unique = [] # Keys that identify this object
1416 self .only = [] # List of all keys in this object, if used
1517 self .types = {} # Dictionary of what keys have special types
@@ -40,7 +42,7 @@ def _assign(self, obj):
4042 else :
4143 self .__cinit__ ()
4244 elif hasattr (self , "__cinit__" ):
43- if str ( type ( self .client )) == "<class ' vrcpy.client.AClient'>" :
45+ if isinstance ( self .client , vrcpy .client .AClient ) :
4446 async def di1 (self ):
4547 async def di2 (self ):
4648 raise AttributeError (self .objType + " object has no attribute 'do_init'" )
@@ -63,18 +65,18 @@ def di2(self):
6365 self ._dict = obj
6466
6567 def _objectIntegrety (self , obj ):
66- if self .only == [] :
68+ if not self .only :
6769 for key in self .unique :
68- if not key in obj :
70+ if key not in obj :
6971 raise IntegretyError ("Object does not have unique key (" + key + ") for " + self .objType +
7072 " (Class definition may be outdated, please make an issue on github)" )
7173 else :
7274 for key in obj :
73- if not key in self .only :
75+ if key not in self .only :
7476 raise IntegretyError ("Object has key not found in " + self .objType +
7577 " (Class definition may be outdated, please make an issue on github)" )
7678 for key in self .only :
77- if not key in obj :
79+ if key not in obj :
7880 raise IntegretyError ("Object does not have requred key (" + key + ") for " + self .objType +
7981 " (Class definition may be outdated, please make an issue on github)" )
8082
@@ -112,6 +114,7 @@ def select(self):
112114
113115 def __init__ (self , client , obj ):
114116 super ().__init__ (client )
117+ self .authorId = None
115118 self .unique += [
116119 "authorId" ,
117120 "authorName" ,
@@ -193,7 +196,7 @@ def __init__(self, client, obj=None):
193196 "instanceId" : Location
194197 })
195198
196- if not obj == None :
199+ if obj is not None :
197200 self ._assign (obj )
198201 if not hasattr (self , "bio" ):
199202 self .bio = ""
@@ -208,7 +211,7 @@ def __init__(self, client, obj=None):
208211 "allowAvatarCopying"
209212 ]
210213
211- if not obj == None :
214+ if obj is not None :
212215 self ._assign (obj )
213216
214217
@@ -276,7 +279,7 @@ def update_info(self, email=None, status=None,
276279 "bio" : bio , "bioLinks" : bioLinks }
277280
278281 for p in params :
279- if params [p ] == None :
282+ if params [p ] is None :
280283 params [p ] = getattr (self , p )
281284
282285 resp = self .client .api .call ("/users/" + self .id , "PUT" , params = params )
@@ -424,6 +427,7 @@ def favorite(self):
424427
425428 def __init__ (self , client , obj = None ):
426429 super ().__init__ (client )
430+ self .authorId = None
427431 self .unique += [
428432 "visits" ,
429433 "occupants" ,
@@ -434,7 +438,7 @@ def __init__(self, client, obj=None):
434438 "unityPackages" : UnityPackage
435439 })
436440
437- if not obj == None :
441+ if obj is not None :
438442 self ._assign (obj )
439443
440444
@@ -478,7 +482,7 @@ class Location:
478482 objType = "Location"
479483
480484 def __init__ (self , client , location ):
481- if not type (location ) == str :
485+ if not isinstance (location , str ) :
482486 raise TypeError ("Expected string, got " + str (type (location )))
483487
484488 self .nonce = None
@@ -501,10 +505,10 @@ def __init__(self, client, location):
501505 self .type , self .userId = t [:- 1 ].split ("(" )
502506 self .nonce = nonce .split ("(" )[1 ][:- 1 ]
503507 elif location .count ("~" ) == 1 :
504- self .name , self .type = location .split ("~" ) # Needs testing, https://github.com/vrchatapi/VRChatPython/issues/17
508+ self .name , self .type = location .split ("~" ) # Needs testing, https://github.com/vrchatapi/VRChatPython/issues/17
505509 else :
506510 self .name = location
507- except Exception as e : # https://github.com/vrchatapi/VRChatPython/issues/17
511+ except Exception as e : # https://github.com/vrchatapi/VRChatPython/issues/17
508512 raise GeneralError ("Exception occured while trying to parse location string ({})! Please open an issue on github! {}" .format (originalLocation , e ))
509513
510514
@@ -538,6 +542,9 @@ def join(self):
538542
539543 def __init__ (self , client , obj ):
540544 super ().__init__ (client )
545+ self .worldId = None
546+ self .location = None
547+ self .shortName = None
541548 self .unique += [
542549 "n_users" ,
543550 "instanceId" ,
@@ -619,6 +626,8 @@ def __cinit__(self):
619626
620627 def __init__ (self , client , obj ):
621628 super ().__init__ (client )
629+ self .type = None
630+ self .favoriteId = None
622631
623632 self .unique += [
624633 "id" ,
0 commit comments