diff --git a/gen_wrap.py b/gen_wrap.py index 4a1caa9..c38ef87 100644 --- a/gen_wrap.py +++ b/gen_wrap.py @@ -1468,41 +1468,6 @@ def write_exposer( f' isl::handle_isl_error(ctx, "isl_{meth.cls}_read_from_str");' '}, py::arg("s"), py::arg("context").none(true)=py::none());\n') - # Handle auto-self-downcasts. These are deprecated. - if not meth.is_static: - for basic_cls in AUTO_DOWNCASTS.get(meth.cls, []): - basic_overloads = meth_to_overloads.setdefault((basic_cls, meth.name), []) - if any(basic_meth - for basic_meth in basic_overloads - if (basic_meth.is_static - or meth.arg_types()[1:] == basic_meth.arg_types()[1:]) - ): - continue - - # These are high-traffic APIs that are manually implemented - # and not subject to deprecation. - if basic_cls == "basic_set": - if meth.name in ["is_params", "get_hash"]: - continue - elif basic_cls == "basic_map" and meth.name in ["get_hash"]: - continue - - basic_overloads.append(meth) - - downcast_doc_str = (f"{doc_str}\n\nDowncast from " - f":class:`{to_py_class(basic_cls)}` to " - f":class:`{to_py_class(meth.cls)}`.") - escaped_doc_str = downcast_doc_str.replace(newline, escaped_newline) - outf.write(f"// automatic downcast to {meth.cls}\n") - outf.write(f'wrap_{basic_cls}.def(' - # Do not be tempted to pass 'arg_str' here, it will - # prevent implicit conversion. - # https://github.com/wjakob/nanobind/issues/1061 - f'"{py_name}", {func_name}' - f', py::sig("def {py_name}{type_sig}")' - f', "{py_name}{type_sig}\\n{escaped_doc_str}"' - ');\n') - # }}} diff --git a/islpy/_monkeypatch.py b/islpy/_monkeypatch.py index c0cdec3..a1920e5 100644 --- a/islpy/_monkeypatch.py +++ b/islpy/_monkeypatch.py @@ -1216,57 +1216,3 @@ def _add_functionality() -> None: "Map": "to_map", "UnionMap": "to_union_map", } - - -def _depr_downcast_wrapper( - f: Callable[Concatenate[object, P], ResultT], - ) -> Callable[Concatenate[object, P], ResultT]: - doc = f.__doc__ - assert doc is not None - m = _DOWNCAST_RE.search(doc) - assert m, doc - basic_cls_name = intern(m.group(1)) - tgt_cls_name = m.group(2) - - tgt_cls = cast("type", getattr(_isl, tgt_cls_name)) - is_overload = "Overloaded function" in doc - msg = (f"{basic_cls_name}.{f.__name__} " - f"with implicit conversion of self to {tgt_cls_name} is deprecated " - "and will stop working in 2026. " - f"Explicitly convert to {tgt_cls_name}, " - f"using .{_TO_METHODS[tgt_cls_name]}().") - - if is_overload: - def wrapper(self: object, *args: P.args, **kwargs: P.kwargs) -> ResultT: - # "Try to" detect bad invocations of, e.g., Set.union, which is - # an overload of normal union and UnionSet.union. - if ( - any(isinstance(arg, tgt_cls) for arg in args) - or - any(isinstance(arg, tgt_cls) for arg in kwargs.values()) - ): - warn(msg, DeprecationWarning, stacklevel=2) - - return f(self, *args, **kwargs) - else: - def wrapper(self: object, *args: P.args, **kwargs: P.kwargs) -> ResultT: - warn(msg, DeprecationWarning, stacklevel=2) - - return f(self, *args, **kwargs) - update_wrapper(wrapper, f) - return wrapper - - -def _monkeypatch_self_downcast_deprecation(): - for cls in ALL_CLASSES: - for attr_name in dir(cls): - val = cast("object", getattr(cls, attr_name)) - doc = getattr(val, "__doc__", None) - if doc and "\nDowncast from " in doc: - setattr(cls, attr_name, _depr_downcast_wrapper( - cast("Callable", val), # pyright: ignore[reportMissingTypeArgument] - )) - - -if not os.environ.get("ISLPY_NO_DOWNCAST_DEPRECATION", None): - _monkeypatch_self_downcast_deprecation()