@@ -844,7 +844,7 @@ def _encode_binary(data: bytes, subtype: int, json_options: JSONOptions) -> Any:
844844 return {"$binary" : {"base64" : base64 .b64encode (data ).decode (), "subType" : "%02x" % subtype }}
845845
846846
847- def _encode_datetimems (obj : Any , json_options : JSONOptions ) -> dict :
847+ def _encode_datetimems (obj : Any , json_options : JSONOptions ) -> dict : # type: ignore[type-arg]
848848 if (
849849 json_options .datetime_representation == DatetimeRepresentation .ISO8601
850850 and 0 <= int (obj ) <= _MAX_UTC_MS
@@ -855,7 +855,7 @@ def _encode_datetimems(obj: Any, json_options: JSONOptions) -> dict:
855855 return {"$date" : {"$numberLong" : str (int (obj ))}}
856856
857857
858- def _encode_code (obj : Code , json_options : JSONOptions ) -> dict :
858+ def _encode_code (obj : Code , json_options : JSONOptions ) -> dict : # type: ignore[type-arg]
859859 if obj .scope is None :
860860 return {"$code" : str (obj )}
861861 else :
@@ -873,7 +873,7 @@ def _encode_noop(obj: Any, dummy0: Any) -> Any:
873873 return obj
874874
875875
876- def _encode_regex (obj : Any , json_options : JSONOptions ) -> dict :
876+ def _encode_regex (obj : Any , json_options : JSONOptions ) -> dict : # type: ignore[type-arg]
877877 flags = ""
878878 if obj .flags & re .IGNORECASE :
879879 flags += "i"
@@ -918,7 +918,7 @@ def _encode_float(obj: float, json_options: JSONOptions) -> Any:
918918 return obj
919919
920920
921- def _encode_datetime (obj : datetime .datetime , json_options : JSONOptions ) -> dict :
921+ def _encode_datetime (obj : datetime .datetime , json_options : JSONOptions ) -> dict : # type: ignore[type-arg]
922922 if json_options .datetime_representation == DatetimeRepresentation .ISO8601 :
923923 if not obj .tzinfo :
924924 obj = obj .replace (tzinfo = utc )
@@ -941,51 +941,51 @@ def _encode_datetime(obj: datetime.datetime, json_options: JSONOptions) -> dict:
941941 return {"$date" : {"$numberLong" : str (millis )}}
942942
943943
944- def _encode_bytes (obj : bytes , json_options : JSONOptions ) -> dict :
944+ def _encode_bytes (obj : bytes , json_options : JSONOptions ) -> dict : # type: ignore[type-arg]
945945 return _encode_binary (obj , 0 , json_options )
946946
947947
948- def _encode_binary_obj (obj : Binary , json_options : JSONOptions ) -> dict :
948+ def _encode_binary_obj (obj : Binary , json_options : JSONOptions ) -> dict : # type: ignore[type-arg]
949949 return _encode_binary (obj , obj .subtype , json_options )
950950
951951
952- def _encode_uuid (obj : uuid .UUID , json_options : JSONOptions ) -> dict :
952+ def _encode_uuid (obj : uuid .UUID , json_options : JSONOptions ) -> dict : # type: ignore[type-arg]
953953 if json_options .strict_uuid :
954954 binval = Binary .from_uuid (obj , uuid_representation = json_options .uuid_representation )
955955 return _encode_binary (binval , binval .subtype , json_options )
956956 else :
957957 return {"$uuid" : obj .hex }
958958
959959
960- def _encode_objectid (obj : ObjectId , dummy0 : Any ) -> dict :
960+ def _encode_objectid (obj : ObjectId , dummy0 : Any ) -> dict : # type: ignore[type-arg]
961961 return {"$oid" : str (obj )}
962962
963963
964- def _encode_timestamp (obj : Timestamp , dummy0 : Any ) -> dict :
964+ def _encode_timestamp (obj : Timestamp , dummy0 : Any ) -> dict : # type: ignore[type-arg]
965965 return {"$timestamp" : {"t" : obj .time , "i" : obj .inc }}
966966
967967
968- def _encode_decimal128 (obj : Timestamp , dummy0 : Any ) -> dict :
968+ def _encode_decimal128 (obj : Timestamp , dummy0 : Any ) -> dict : # type: ignore[type-arg]
969969 return {"$numberDecimal" : str (obj )}
970970
971971
972- def _encode_dbref (obj : DBRef , json_options : JSONOptions ) -> dict :
972+ def _encode_dbref (obj : DBRef , json_options : JSONOptions ) -> dict : # type: ignore[type-arg]
973973 return _json_convert (obj .as_doc (), json_options = json_options )
974974
975975
976- def _encode_minkey (dummy0 : Any , dummy1 : Any ) -> dict :
976+ def _encode_minkey (dummy0 : Any , dummy1 : Any ) -> dict : # type: ignore[type-arg]
977977 return {"$minKey" : 1 }
978978
979979
980- def _encode_maxkey (dummy0 : Any , dummy1 : Any ) -> dict :
980+ def _encode_maxkey (dummy0 : Any , dummy1 : Any ) -> dict : # type: ignore[type-arg]
981981 return {"$maxKey" : 1 }
982982
983983
984984# Encoders for BSON types
985985# Each encoder function's signature is:
986986# - obj: a Python data type, e.g. a Python int for _encode_int
987987# - json_options: a JSONOptions
988- _ENCODERS : dict [Type , Callable [[Any , JSONOptions ], Any ]] = {
988+ _ENCODERS : dict [Type , Callable [[Any , JSONOptions ], Any ]] = { # type: ignore[type-arg]
989989 bool : _encode_noop ,
990990 bytes : _encode_bytes ,
991991 datetime .datetime : _encode_datetime ,
@@ -1056,7 +1056,7 @@ def _get_datetime_size(obj: datetime.datetime) -> int:
10561056 return 5 + len (str (obj .time ()))
10571057
10581058
1059- def _get_regex_size (obj : Regex ) -> int :
1059+ def _get_regex_size (obj : Regex ) -> int : # type: ignore[type-arg]
10601060 return 18 + len (obj .pattern )
10611061
10621062
0 commit comments