@@ -844,7 +844,7 @@ def _encode_binary(data: bytes, subtype: int, json_options: JSONOptions) -> Any:
844
844
return {"$binary" : {"base64" : base64 .b64encode (data ).decode (), "subType" : "%02x" % subtype }}
845
845
846
846
847
- def _encode_datetimems (obj : Any , json_options : JSONOptions ) -> dict :
847
+ def _encode_datetimems (obj : Any , json_options : JSONOptions ) -> dict :# type: ignore[type-arg]
848
848
if (
849
849
json_options .datetime_representation == DatetimeRepresentation .ISO8601
850
850
and 0 <= int (obj ) <= _MAX_UTC_MS
@@ -855,7 +855,7 @@ def _encode_datetimems(obj: Any, json_options: JSONOptions) -> dict:
855
855
return {"$date" : {"$numberLong" : str (int (obj ))}}
856
856
857
857
858
- def _encode_code (obj : Code , json_options : JSONOptions ) -> dict :
858
+ def _encode_code (obj : Code , json_options : JSONOptions ) -> dict :# type: ignore[type-arg]
859
859
if obj .scope is None :
860
860
return {"$code" : str (obj )}
861
861
else :
@@ -873,7 +873,7 @@ def _encode_noop(obj: Any, dummy0: Any) -> Any:
873
873
return obj
874
874
875
875
876
- def _encode_regex (obj : Any , json_options : JSONOptions ) -> dict :
876
+ def _encode_regex (obj : Any , json_options : JSONOptions ) -> dict :# type: ignore[type-arg]
877
877
flags = ""
878
878
if obj .flags & re .IGNORECASE :
879
879
flags += "i"
@@ -918,7 +918,7 @@ def _encode_float(obj: float, json_options: JSONOptions) -> Any:
918
918
return obj
919
919
920
920
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]
922
922
if json_options .datetime_representation == DatetimeRepresentation .ISO8601 :
923
923
if not obj .tzinfo :
924
924
obj = obj .replace (tzinfo = utc )
@@ -941,51 +941,51 @@ def _encode_datetime(obj: datetime.datetime, json_options: JSONOptions) -> dict:
941
941
return {"$date" : {"$numberLong" : str (millis )}}
942
942
943
943
944
- def _encode_bytes (obj : bytes , json_options : JSONOptions ) -> dict :
944
+ def _encode_bytes (obj : bytes , json_options : JSONOptions ) -> dict :# type: ignore[type-arg]
945
945
return _encode_binary (obj , 0 , json_options )
946
946
947
947
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]
949
949
return _encode_binary (obj , obj .subtype , json_options )
950
950
951
951
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]
953
953
if json_options .strict_uuid :
954
954
binval = Binary .from_uuid (obj , uuid_representation = json_options .uuid_representation )
955
955
return _encode_binary (binval , binval .subtype , json_options )
956
956
else :
957
957
return {"$uuid" : obj .hex }
958
958
959
959
960
- def _encode_objectid (obj : ObjectId , dummy0 : Any ) -> dict :
960
+ def _encode_objectid (obj : ObjectId , dummy0 : Any ) -> dict :# type: ignore[type-arg]
961
961
return {"$oid" : str (obj )}
962
962
963
963
964
- def _encode_timestamp (obj : Timestamp , dummy0 : Any ) -> dict :
964
+ def _encode_timestamp (obj : Timestamp , dummy0 : Any ) -> dict :# type: ignore[type-arg]
965
965
return {"$timestamp" : {"t" : obj .time , "i" : obj .inc }}
966
966
967
967
968
- def _encode_decimal128 (obj : Timestamp , dummy0 : Any ) -> dict :
968
+ def _encode_decimal128 (obj : Timestamp , dummy0 : Any ) -> dict :# type: ignore[type-arg]
969
969
return {"$numberDecimal" : str (obj )}
970
970
971
971
972
- def _encode_dbref (obj : DBRef , json_options : JSONOptions ) -> dict :
972
+ def _encode_dbref (obj : DBRef , json_options : JSONOptions ) -> dict :# type: ignore[type-arg]
973
973
return _json_convert (obj .as_doc (), json_options = json_options )
974
974
975
975
976
- def _encode_minkey (dummy0 : Any , dummy1 : Any ) -> dict :
976
+ def _encode_minkey (dummy0 : Any , dummy1 : Any ) -> dict :# type: ignore[type-arg]
977
977
return {"$minKey" : 1 }
978
978
979
979
980
- def _encode_maxkey (dummy0 : Any , dummy1 : Any ) -> dict :
980
+ def _encode_maxkey (dummy0 : Any , dummy1 : Any ) -> dict :# type: ignore[type-arg]
981
981
return {"$maxKey" : 1 }
982
982
983
983
984
984
# Encoders for BSON types
985
985
# Each encoder function's signature is:
986
986
# - obj: a Python data type, e.g. a Python int for _encode_int
987
987
# - json_options: a JSONOptions
988
- _ENCODERS : dict [Type , Callable [[Any , JSONOptions ], Any ]] = {
988
+ _ENCODERS : dict [Type , Callable [[Any , JSONOptions ], Any ]] = {# type: ignore[type-arg]
989
989
bool : _encode_noop ,
990
990
bytes : _encode_bytes ,
991
991
datetime .datetime : _encode_datetime ,
@@ -1056,7 +1056,7 @@ def _get_datetime_size(obj: datetime.datetime) -> int:
1056
1056
return 5 + len (str (obj .time ()))
1057
1057
1058
1058
1059
- def _get_regex_size (obj : Regex ) -> int :
1059
+ def _get_regex_size (obj : Regex ) -> int :# type: ignore[type-arg]
1060
1060
return 18 + len (obj .pattern )
1061
1061
1062
1062
0 commit comments