{"record":{"id":"afc2f80189f61eb4","repo":"pandas-dev/pandas","slug":"invalid-validation-method-method","errorCode":null,"errorMessage":"invalid validation method '{method}'","messagePattern":"invalid validation method '(.+?)'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"pandas/compat/numpy/function.py","lineNumber":93,"sourceCode":"\n        fname = self.fname if fname is None else fname\n        max_fname_arg_count = (\n            self.max_fname_arg_count\n            if max_fname_arg_count is None\n            else max_fname_arg_count\n        )\n        method = self.method if method is None else method\n\n        if method == \"args\":\n            validate_args(fname, args, cast(\"int\", max_fname_arg_count), self.defaults)\n        elif method == \"kwargs\":\n            validate_kwargs(fname, kwargs, self.defaults)\n        elif method == \"both\":\n            validate_args_and_kwargs(\n                fname, args, kwargs, cast(\"int\", max_fname_arg_count), self.defaults\n            )\n        else:\n            raise ValueError(f\"invalid validation method '{method}'\")\n\n\nARGMINMAX_DEFAULTS = {\"out\": None}\nvalidate_argmin = CompatValidator(\n    ARGMINMAX_DEFAULTS, fname=\"argmin\", method=\"both\", max_fname_arg_count=1\n)\nvalidate_argmax = CompatValidator(\n    ARGMINMAX_DEFAULTS, fname=\"argmax\", method=\"both\", max_fname_arg_count=1\n)\n\n\ndef process_skipna(\n    skipna: bool | ndarray | None, args: tuple[Any, ...]\n) -> tuple[bool, tuple[Any, ...]]:\n    if isinstance(skipna, ndarray) or skipna is None:\n        args = (skipna, *args)\n        skipna = True\n","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/compat/numpy/function.py#L75-L111","documentation":"Raised by `CompatValidator.validate` in pandas.compat.numpy.function when the `method` argument is not one of the supported values: `'args'`, `'kwargs'`, or `'both'`. These validators mirror numpy's argument signature validation for methods pandas delegates to numpy (argmin, argmax, etc.). An unknown method indicates a programming error in registering or invoking a validator.","triggerScenarios":"Constructing a `CompatValidator(..., method='something')` with an invalid method string; calling `validator.validate(..., method='nope')`. This is essentially only reachable from internal pandas code or plugins extending the numpy-compat layer.","commonSituations":"Typos in validator registration; downstream libraries subclassing the CompatValidator; pandas internal refactor introducing a new method without updating the dispatch.","solutions":["Use one of the three documented methods: 'args', 'kwargs', or 'both'.","If you wrote a custom validator, audit the method value passed to `.validate()`.","Search the codebase for `CompatValidator(` to find the offending registration."],"exampleFix":"// before\nv = CompatValidator(defaults, fname='op', method='arguments')\n\n// after\nv = CompatValidator(defaults, fname='op', method='args')","handlingStrategy":"validation","validationCode":"assert method in {'args', 'kwargs', 'both'}, f'invalid method {method}'","typeGuard":"from typing import Literal\nValidMethod = Literal['args', 'kwargs', 'both']","tryCatchPattern":null,"preventionTips":["Use the Literal type for method parameters.","Keep CompatValidator registrations in a single constants module to catch typos."],"tags":["internal","numpy-compat","argument-validation"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}