{"record":{"id":"20ac082c8fb266cb","repo":"astral-sh/ruff","slug":"missing-argument-member","errorCode":null,"errorMessage":"Missing argument `member`","messagePattern":"Missing argument `member`","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ruff_linter/src/rules/flake8_pytest_style/rules/unittest_assert.rs","lineNumber":347,"sourceCode":"                    | UnittestAssert::FailUnlessEqual => CmpOp::Eq,\n                    UnittestAssert::NotEqual\n                    | UnittestAssert::NotEquals\n                    | UnittestAssert::FailIfEqual => CmpOp::NotEq,\n                    UnittestAssert::Greater => CmpOp::Gt,\n                    UnittestAssert::GreaterEqual => CmpOp::GtE,\n                    UnittestAssert::Less => CmpOp::Lt,\n                    UnittestAssert::LessEqual => CmpOp::LtE,\n                    UnittestAssert::Is => CmpOp::Is,\n                    UnittestAssert::IsNot => CmpOp::IsNot,\n                    _ => unreachable!(),\n                };\n                let expr = compare(first, cmp_op, second);\n                Ok(assert(&expr, msg))\n            }\n            UnittestAssert::In | UnittestAssert::NotIn => {\n                let member = args\n                    .get(\"member\")\n                    .ok_or_else(|| anyhow!(\"Missing argument `member`\"))?;\n                let container = args\n                    .get(\"container\")\n                    .ok_or_else(|| anyhow!(\"Missing argument `container`\"))?;\n                let msg = args.get(\"msg\").copied();\n                let cmp_op = if matches!(self, UnittestAssert::In) {\n                    CmpOp::In\n                } else {\n                    CmpOp::NotIn\n                };\n                let expr = compare(member, cmp_op, container);\n                Ok(assert(&expr, msg))\n            }\n            UnittestAssert::IsNone | UnittestAssert::IsNotNone => {\n                let expr = args\n                    .get(\"expr\")\n                    .ok_or_else(|| anyhow!(\"Missing argument `expr`\"))?;\n                let msg = args.get(\"msg\").copied();\n                let cmp_op = if matches!(self, UnittestAssert::IsNone) {","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/astral-sh/ruff/blob/15f3fe6b15a5f00172f34b0f542f8ea277f5a586/crates/ruff_linter/src/rules/flake8_pytest_style/rules/unittest_assert.rs#L329-L365","documentation":"`generate_assert` handles `assertIn`/`assertNotIn` by emitting `assert member in container`. When the rewritten call's argument map lacks a `\"member\"` entry (the first required argument), the rewrite fails with this error and no fix is produced.","triggerScenarios":"`UnittestAssert::In | NotIn.generate_assert` where the source `self.assertIn(...)` call supplied zero positional args or skipped `member` without a `member=` keyword (e.g. only `container`/`msg` given).","commonSituations":"Incomplete `assertIn()` calls in suites being bulk-fixed with PT009; dynamically defined methods named `assertIn` on non-unittest classes with different signatures.","solutions":["Fix the call to pass the value first: `self.assertIn(item, collection)`.","Disable rule PT009 (`lint.ignore = [\"PT009\"]`) if unittest asserts should not be rewritten.","If editing Ruff, verify `arg_spec = ['member', 'container', 'msg']` and the positional/keyword collection in `args_map`.","Run `ruff check --no-fix` to pinpoint the exact call being rewritten."],"exampleFix":"// before\nself.assertIn(key='k', container=d)\n// after\nself.assertIn('k', d)","handlingStrategy":"validation","validationCode":"def valid_assert_in(call_args, call_kwargs):\n    return len(call_args) >= 1 or 'member' in call_kwargs","typeGuard":"def is_membership_assert(args: tuple, kwargs: dict) -> bool:\n    return (len(args) >= 1 or 'member' in kwargs) and (len(args) >= 2 or 'container' in kwargs)","tryCatchPattern":null,"preventionTips":["Call assertIn/assertNotIn with the value first, then the container.","Enable `ruff check` in pre-commit so incomplete asserts never reach --fix.","Suppress PT009 per-file for classes with custom same-named assert helpers.","Keep container construction outside the assert so arguments are not dropped during edits."],"tags":["linter","rust","pytest-style","argument-missing"],"backgroundTag":"missing-required-argument","analyzedSha":"15f3fe6b15a5f00172f34b0f542f8ea277f5a586","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}