mirror of
				https://github.com/RGBCube/GitHubWrapper
				synced 2025-10-31 14:02:46 +00:00 
			
		
		
		
	Make HTTPClient.request use orjson if it exists
This commit is contained in:
		
							parent
							
								
									0a2efb58cd
								
							
						
					
					
						commit
						5d1ce5b572
					
				
					 2 changed files with 2 additions and 3 deletions
				
			
		|  | @ -23,7 +23,6 @@ def make_link_role(resource_links: Dict[str, str]) -> RoleFunction: | ||||||
|         options: Dict = {}, |         options: Dict = {}, | ||||||
|         content: List[str] = [], |         content: List[str] = [], | ||||||
|     ) -> Tuple[List[Node], List[system_message]]: |     ) -> Tuple[List[Node], List[system_message]]: | ||||||
| 
 |  | ||||||
|         text = utils.unescape(text) |         text = utils.unescape(text) | ||||||
|         has_explicit_title, title, key = split_explicit_title(text) |         has_explicit_title, title, key = split_explicit_title(text) | ||||||
|         full_url = resource_links[key] |         full_url = resource_links[key] | ||||||
|  |  | ||||||
|  | @ -18,6 +18,7 @@ try: | ||||||
|     import orjson |     import orjson | ||||||
| except ImportError: | except ImportError: | ||||||
|     import json |     import json | ||||||
|  | 
 | ||||||
|     json_loads = json.loads |     json_loads = json.loads | ||||||
| else: | else: | ||||||
|     json_loads = orjson.loads |     json_loads = orjson.loads | ||||||
|  | @ -188,7 +189,6 @@ class HTTPClient: | ||||||
|         async with self.__session.request( |         async with self.__session.request( | ||||||
|             method, f"https://api.github.com{path}", **kwargs |             method, f"https://api.github.com{path}", **kwargs | ||||||
|         ) as response: |         ) as response: | ||||||
| 
 |  | ||||||
|             headers = response.headers |             headers = response.headers | ||||||
| 
 | 
 | ||||||
|             self._rates = RateLimits( |             self._rates = RateLimits( | ||||||
|  | @ -202,7 +202,7 @@ class HTTPClient: | ||||||
|             ) |             ) | ||||||
| 
 | 
 | ||||||
|             if 200 <= response.status <= 299: |             if 200 <= response.status <= 299: | ||||||
|                 data = await response.text(encoding='utf-8') |                 data = await response.text(encoding="utf-8") | ||||||
| 
 | 
 | ||||||
|                 if response.headers["Content-Type"] == "application/json": |                 if response.headers["Content-Type"] == "application/json": | ||||||
|                     return json_loads(data) |                     return json_loads(data) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 RGBCube
						RGBCube