mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 14:03:30 +00:00 
			
		
		
		
	refactor: Remove dict_with_str_keys().
This function is no longer needed in python3, as it was decoding keys that already came for a JSON-decoded string.
This commit is contained in:
		@@ -15,7 +15,6 @@ from zerver.lib.cache import (
 | 
			
		||||
    to_dict_cache_key_id,
 | 
			
		||||
)
 | 
			
		||||
from zerver.lib.request import JsonableError
 | 
			
		||||
from zerver.lib.str_utils import dict_with_str_keys
 | 
			
		||||
from zerver.lib.stream_subscription import (
 | 
			
		||||
    get_stream_subscriptions_for_user,
 | 
			
		||||
)
 | 
			
		||||
@@ -111,7 +110,7 @@ def sew_messages_and_reactions(messages, reactions):
 | 
			
		||||
 | 
			
		||||
def extract_message_dict(message_bytes):
 | 
			
		||||
    # type: (bytes) -> Dict[str, Any]
 | 
			
		||||
    return dict_with_str_keys(ujson.loads(zlib.decompress(message_bytes).decode("utf-8")))
 | 
			
		||||
    return ujson.loads(zlib.decompress(message_bytes).decode("utf-8"))
 | 
			
		||||
 | 
			
		||||
def stringify_message_dict(message_dict):
 | 
			
		||||
    # type: (Dict[str, Any]) -> bytes
 | 
			
		||||
 
 | 
			
		||||
@@ -66,11 +66,6 @@ def force_str(s, encoding='utf-8'):
 | 
			
		||||
    else:
 | 
			
		||||
        raise TypeError("force_str expects a string type")
 | 
			
		||||
 | 
			
		||||
def dict_with_str_keys(dct, encoding='utf-8'):
 | 
			
		||||
    # type: (Mapping[NonBinaryStr, Any], str) -> Dict[str, Any]
 | 
			
		||||
    """applies force_str on the keys of a dict (non-recursively)"""
 | 
			
		||||
    return {force_str(key, encoding): value for key, value in dct.items()}
 | 
			
		||||
 | 
			
		||||
class ModelReprMixin:
 | 
			
		||||
    """
 | 
			
		||||
    This mixin provides a python 2 and 3 compatible way of handling string representation of a model.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user