code: def deprecate_nonkeyword_arguments(
      allowed_args: list[str] | None = None,
      message: str | None = None,
      *,
      version: str,
  ) -> Callable[[Callable[P, T]], Callable[P, T]]:
      """
      Decorator to deprecate the use of non-keyword arguments of a function.
  
      Parameters
      ----------
      allowed_args
          The names of some first arguments of the decorated function that are allowed to
          be given as positional arguments. Should include "self" when decorating class
          methods. If set to None (default), equal to all arguments that do not have a
          default value.
      message
          Optionally overwrite the default warning message.
      version
          The Polars version number in which the warning is first issued.
          This argument is used to help developers determine when to remove the
          deprecated functionality.
  
      """
  
      def decorate(function: Callable[P, T]) -> Callable[P, T]:
          old_sig = inspect.signature(function)
  
          if allowed_args is not None:
              allow_args = allowed_args
          else:
              allow_args = [
                  p.name
                  for p in old_sig.parameters.values()
                  if p.kind
                  in (p.POSITIONAL_ONLY, p.POSITIONAL_OR_KEYWORD)
                  and p.default is p.empty
              ]
  
          new_params = [
              p.replace(kind=p.KEYWORD_ONLY)
              if (
                  p.kind in (p.POSITIONAL_ONLY, p.POSITIONAL_OR_KEYWORD)
                  and p.name not in allow_args
              )
              else p
              for p in old_sig.parameters.values()
          ]
          new_params.sort(key=lambda p: p.kind)
  
          new_sig = old_sig.replace(parameters=new_params)
  
          num_allowed_args = len(allow_args)
          if message is None:
              msg_format = (
                  f"All arguments of {function.__qualname__}{{except_args}} will be keyword-only in the next breaking release."
                  " Use keyword arguments to silence this warning."
              )
              msg = msg_format.format(
                  except_args=_format_argument_list(allow_args)
              )
          else:
              msg = message
  
          @wraps(function)
          def wrapper(*args: P.args, **kwargs: P.kwargs) -> T:
              if len(args) > num_allowed_args:
                  issue_deprecation_warning(msg, version=version)
              return function(*args, **kwargs)
  
          wrapper.__signature__ = new_sig  # type: ignore[attr-defined]
          return wrapper
  
      return decorate
  
file_path: polars/py-polars/polars/utils/deprecation.py
imports: from __future__ import annotations
  import inspect
  import warnings
  from functools import wraps
  from typing import TYPE_CHECKING, Callable, TypeVar
  from polars.utils.various import find_stacklevel
label_desc: Use image node_id 6 for calling a global function with example usage: deprecate_nonkeyword_arguments(allowed_args, message) and returns: decorate, wrapper, function