{"record":{"id":"2a31b89605d5efe8","repo":"apache/beam","slug":"func-name-got-too-many-positioned-arguments","errorCode":null,"errorMessage":"{func.__name__} got too many positioned arguments.","messagePattern":"(.+?) got too many positioned arguments\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/dataframe/frame_base.py","lineNumber":517,"sourceCode":"\n    # We would need to add position only arguments if they ever become a thing\n    # in Pandas (as of 2.1 currently they aren't).\n    base_arg_spec = getfullargspec(unwrap(getattr(base_type, func.__name__)))\n    base_arg_names = base_arg_spec.args\n    # Some arguments are keyword only and we still want to check against those.\n    all_possible_base_arg_names = base_arg_names + base_arg_spec.kwonlyargs\n    beam_arg_names = getfullargspec(func).args\n\n    if not_found := (set(beam_arg_names) - set(all_possible_base_arg_names) -\n                     set(removed_arg_names)):\n      raise TypeError(\n          f\"Beam definition of {func.__name__} has arguments that are not found\"\n          f\" in the base version of the function: {not_found}\")\n\n    @functools.wraps(func)\n    def wrapper(*args, **kwargs):\n      if len(args) > len(base_arg_names):\n        raise TypeError(f\"{func.__name__} got too many positioned arguments.\")\n\n      for name, value in zip(base_arg_names, args):\n        if name in kwargs:\n          raise TypeError(\n              \"%s() got multiple values for argument '%s'\" %\n              (func.__name__, name))\n        kwargs[name] = value\n      # Still have to populate these for the Beam function signature.\n      if removed_args:\n        for name in removed_args:\n          if name not in kwargs:\n            kwargs[name] = None\n      return func(**kwargs)\n\n    return wrapper\n\n  return wrap\n","sourceCodeStart":499,"sourceCodeEnd":535,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/dataframe/frame_base.py#L499-L535","documentation":"frame_base's function wrapper adapts Beam dataframe implementations to the pandas API signature (base_arg_names). It enforces that callers pass no more positional arguments than the pandas base method accepts, raising this TypeError to prevent arguments from silently being misassigned.","triggerScenarios":"Calling a dataframe method with excess positional args, e.g. df.quantile(0.5, 0, 'linear') passing more positionals than the pandas signature, or a Beam-internal shim invoking a wrapped function with stale extra positional arguments.","commonSituations":"Code written against an older pandas signature where extra positional args were tolerated; pandas 2.x changes that removed positional parameters; typos adding an extra argument; calling the Beam wrapper directly instead of through the public method.","solutions":["Remove the extra positional argument or convert it to a keyword argument that the pandas signature accepts.","Check the current pandas signature of the method and update the call site.","If calling the Beam-internal function, pass Beam-specific arguments as keywords rather than positionally."],"exampleFix":"// before\ndf.quantile(0.5, 0, 'linear')\n// after\ndf.quantile(0.5, axis=0, interpolation='linear')","handlingStrategy":"validation","validationCode":"import inspect\nn_base = len(inspect.signature(pd.DataFrame.quantile).parameters)\nassert len(args) <= n_base, 'too many positional arguments'","typeGuard":"def fits_base_signature(args, base_func) -> bool:\n    import inspect\n    return len(args) <= len(inspect.signature(base_func).parameters)","tryCatchPattern":"try:\n    df.quantile(*args)\nexcept TypeError as e:\n    if 'too many positioned' in str(e):\n        df.quantile(*args[:1], **kwargs)\n    else:\n        raise","preventionTips":["Call methods by keyword arguments to make arity errors impossible.","Re-check positional args after pandas major-version upgrades.","Avoid calling Beam's internal wrapped functions directly; use the public dataframe API."],"tags":["python","apache-beam","dataframe-api","argument-count"],"backgroundTag":"invalid-argument","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}