1919import io
2020import math
2121import os
22+ import warnings
2223from typing import Any , Iterable , Mapping , NoReturn , Optional
2324
2425from bson .int64 import Int64
@@ -69,8 +70,15 @@ def _grid_in_property(
6970 closed_only : Optional [bool ] = False ,
7071) -> Any :
7172 """Create a GridIn property."""
73+ warn_str = ""
74+ if docstring .startswith ("DEPRECATED," ):
75+ warn_str = (
76+ f"GridIn property '{ field_name } ' is deprecated and will be removed in PyMongo 5.0"
77+ )
7278
7379 def getter (self : Any ) -> Any :
80+ if warn_str :
81+ warnings .warn (warn_str , stacklevel = 2 , category = DeprecationWarning )
7482 if closed_only and not self ._closed :
7583 raise AttributeError ("can only get %r on a closed file" % field_name )
7684 # Protect against PHP-237
@@ -79,6 +87,8 @@ def getter(self: Any) -> Any:
7987 return self ._file .get (field_name , None )
8088
8189 def setter (self : Any , value : Any ) -> Any :
90+ if warn_str :
91+ warnings .warn (warn_str , stacklevel = 2 , category = DeprecationWarning )
8292 if self ._closed :
8393 self ._coll .files .update_one ({"_id" : self ._file ["_id" ]}, {"$set" : {field_name : value }})
8494 self ._file [field_name ] = value
@@ -100,8 +110,15 @@ def setter(self: Any, value: Any) -> Any:
100110
101111def _grid_out_property (field_name : str , docstring : str ) -> Any :
102112 """Create a GridOut property."""
113+ warn_str = ""
114+ if docstring .startswith ("DEPRECATED," ):
115+ warn_str = (
116+ f"GridOut property '{ field_name } ' is deprecated and will be removed in PyMongo 5.0"
117+ )
103118
104119 def getter (self : Any ) -> Any :
120+ if warn_str :
121+ warnings .warn (warn_str , stacklevel = 2 , category = DeprecationWarning )
105122 self ._ensure_file ()
106123
107124 # Protect against PHP-237
0 commit comments