{"id":"ef293d4e028b19a3","repo":"pytest-dev/pytest","slug":"alias-r-is-already-an-alias-of-already-r","errorCode":null,"errorMessage":"{alias!r} is already an alias of {already!r}","messagePattern":"(.+?) is already an alias of (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/_pytest/config/argparsing.py","lineNumber":364,"sourceCode":"            ini_type = _ini_type_to_member(name, type)\n        if default is NOTSET:\n            if isinstance(ini_type, (tuple, _IniLiteral)):\n                kind = \"union\" if isinstance(ini_type, tuple) else \"Literal\"\n                raise ValueError(\n                    f\"ini option {name!r} has a {kind} type, which has no \"\n                    \"implicit default; pass an explicit `default` to `addini`\"\n                )\n            default = get_ini_default_for_type(ini_type)\n\n        self._inidict[name] = (help, ini_type, default)\n\n        for alias in aliases:\n            if alias in self._inidict:\n                raise ValueError(\n                    f\"alias {alias!r} conflicts with existing configuration option\"\n                )\n            if (already := self._ini_aliases.get(alias)) is not None:\n                raise ValueError(f\"{alias!r} is already an alias of {already!r}\")\n            self._ini_aliases[alias] = name\n\n\ndef get_ini_default_for_type(type: _IniTypeTag) -> Any:\n    \"\"\"\n    Used by addini to get the default value for a given config option type, when\n    default is not supplied.\n    \"\"\"\n    if type in (\"paths\", \"pathlist\", \"args\", \"linelist\"):\n        return []\n    elif type == \"bool\":\n        return False\n    elif type == \"int\":\n        return 0\n    elif type == \"float\":\n        return 0.0\n    else:\n        return \"\"","sourceCodeStart":346,"sourceCodeEnd":382,"githubUrl":"https://github.com/pytest-dev/pytest/blob/98b357f69e380da908740a212288d73b2ee06687/src/_pytest/config/argparsing.py#L346-L382","documentation":"Raised by Parser.addini() when an alias in aliases= is already mapped to a different canonical option. Each alias can only point to one option; attempting to reuse it for a second option is rejected at registration time.","triggerScenarios":"parser.addini('opt1', aliases=['x']) followed by parser.addini('opt2', aliases=['x']). The check at line 363 finds self._ini_aliases['x'] already set to 'opt1'.","commonSituations":"Multiple plugins independently choosing the same short alias; consolidating options and forgetting an alias was already taken; generic alias names like 'verbose' clashing across plugins.","solutions":["Use a unique alias for each option, namespaced by plugin name if needed.","Remove the duplicate alias registration from one of the addini calls.","Audit all plugins' addini aliases to build a non-overlapping set."],"exampleFix":"# before\nparser.addini('opt1', aliases=['v'], help='...')\nparser.addini('opt2', aliases=['v'], help='...')  # already taken\n\n# after\nparser.addini('opt1', aliases=['v'], help='...')\nparser.addini('opt2', aliases=['v2'], help='...')","handlingStrategy":"validation","validationCode":"def check_alias_unique(existing_aliases: dict, alias: str) -> None:\n    if alias in existing_aliases:\n        raise ValueError(f'{alias!r} is already an alias of {existing_aliases[alias]!r}')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Maintain a single registry of aliases across plugins and conftests.","Prefer descriptive, namespaced alias names."],"tags":["pytest","plugin","config","addini","alias","naming-conflict"],"analyzedSha":"98b357f69e380da908740a212288d73b2ee06687","analyzedAt":"2026-08-04T20:26:34.442Z","schemaVersion":2}