Add more type hinting (#23595)
	
		
	
				
					
				
			* Add more type hinting. * Revert joystick_alert changes. * Add typing to statsd. * Update selfdrive/statsd.py * Update selfdrive/test/test_fingerprints.py Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>pj-view-ci-routes
							parent
							
								
									0f95e605f5
								
							
						
					
					
						commit
						aa9e635311
					
				
				 4 changed files with 16 additions and 10 deletions
			
			
		| @ -1,13 +1,15 @@ | |||||||
|  | from typing import Dict, Tuple | ||||||
|  | 
 | ||||||
| from common.xattr import getxattr as getattr1 | from common.xattr import getxattr as getattr1 | ||||||
| from common.xattr import setxattr as setattr1 | from common.xattr import setxattr as setattr1 | ||||||
| 
 | 
 | ||||||
| cached_attributes = {} | cached_attributes: Dict[Tuple, bytes] = {} | ||||||
| def getxattr(path, attr_name): | def getxattr(path: str, attr_name: bytes) -> bytes: | ||||||
|   if (path, attr_name) not in cached_attributes: |   if (path, attr_name) not in cached_attributes: | ||||||
|     response = getattr1(path, attr_name) |     response = getattr1(path, attr_name) | ||||||
|     cached_attributes[(path, attr_name)] = response |     cached_attributes[(path, attr_name)] = response | ||||||
|   return cached_attributes[(path, attr_name)] |   return cached_attributes[(path, attr_name)] | ||||||
| 
 | 
 | ||||||
| def setxattr(path, attr_name, attr_value): | def setxattr(path: str, attr_name: str, attr_value: bytes) -> None: | ||||||
|   cached_attributes.pop((path, attr_name), None) |   cached_attributes.pop((path, attr_name), None) | ||||||
|   return setattr1(path, attr_name, attr_value) |   return setattr1(path, attr_name, attr_value) | ||||||
|  | |||||||
					Loading…
					
					
				
		Reference in new issue