@@ -854,14 +854,15 @@ def obj_eq(self: IslObject, other: object) -> bool:
854854 return self .is_equal (other )
855855
856856
857- def obj_ne ( self : object , other : object ) -> bool :
858- return not self . __eq__ ( other )
857+ def no_eq ( _self : IslObject , _other : object ) -> bool :
858+ raise TypeError ( "equality not available; use manual downcast or try plain_is_equal" )
859859
860860
861861for cls in ALL_CLASSES :
862862 if hasattr (cls , "is_equal" ):
863863 cls .__eq__ = obj_eq
864- cls .__ne__ = obj_ne
864+ else :
865+ cls .__eq__ = no_eq
865866
866867
867868def set_lt (self : _isl .BasicSet | _isl .Set , other : _isl .BasicSet | _isl .Set ) -> bool :
@@ -1216,57 +1217,3 @@ def _add_functionality() -> None:
12161217 "Map" : "to_map" ,
12171218 "UnionMap" : "to_union_map" ,
12181219}
1219-
1220-
1221- def _depr_downcast_wrapper (
1222- f : Callable [Concatenate [object , P ], ResultT ],
1223- ) -> Callable [Concatenate [object , P ], ResultT ]:
1224- doc = f .__doc__
1225- assert doc is not None
1226- m = _DOWNCAST_RE .search (doc )
1227- assert m , doc
1228- basic_cls_name = intern (m .group (1 ))
1229- tgt_cls_name = m .group (2 )
1230-
1231- tgt_cls = cast ("type" , getattr (_isl , tgt_cls_name ))
1232- is_overload = "Overloaded function" in doc
1233- msg = (f"{ basic_cls_name } .{ f .__name__ } "
1234- f"with implicit conversion of self to { tgt_cls_name } is deprecated "
1235- "and will stop working in 2026. "
1236- f"Explicitly convert to { tgt_cls_name } , "
1237- f"using .{ _TO_METHODS [tgt_cls_name ]} ()." )
1238-
1239- if is_overload :
1240- def wrapper (self : object , * args : P .args , ** kwargs : P .kwargs ) -> ResultT :
1241- # "Try to" detect bad invocations of, e.g., Set.union, which is
1242- # an overload of normal union and UnionSet.union.
1243- if (
1244- any (isinstance (arg , tgt_cls ) for arg in args )
1245- or
1246- any (isinstance (arg , tgt_cls ) for arg in kwargs .values ())
1247- ):
1248- warn (msg , DeprecationWarning , stacklevel = 2 )
1249-
1250- return f (self , * args , ** kwargs )
1251- else :
1252- def wrapper (self : object , * args : P .args , ** kwargs : P .kwargs ) -> ResultT :
1253- warn (msg , DeprecationWarning , stacklevel = 2 )
1254-
1255- return f (self , * args , ** kwargs )
1256- update_wrapper (wrapper , f )
1257- return wrapper
1258-
1259-
1260- def _monkeypatch_self_downcast_deprecation ():
1261- for cls in ALL_CLASSES :
1262- for attr_name in dir (cls ):
1263- val = cast ("object" , getattr (cls , attr_name ))
1264- doc = getattr (val , "__doc__" , None )
1265- if doc and "\n Downcast from " in doc :
1266- setattr (cls , attr_name , _depr_downcast_wrapper (
1267- cast ("Callable" , val ), # pyright: ignore[reportMissingTypeArgument]
1268- ))
1269-
1270-
1271- if not os .environ .get ("ISLPY_NO_DOWNCAST_DEPRECATION" , None ):
1272- _monkeypatch_self_downcast_deprecation ()
0 commit comments