{"record":{"id":"300ad9baf1fd47fb","repo":"astral-sh/ruff","slug":"missing-argument-container","errorCode":null,"errorMessage":"Missing argument `container`","messagePattern":"Missing argument `container`","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ruff_linter/src/rules/flake8_pytest_style/rules/unittest_assert.rs","lineNumber":350,"sourceCode":"                    | 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) {\n                    CmpOp::Is\n                } else {\n                    CmpOp::IsNot","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/astral-sh/ruff/blob/15f3fe6b15a5f00172f34b0f542f8ea277f5a586/crates/ruff_linter/src/rules/flake8_pytest_style/rules/unittest_assert.rs#L332-L368","documentation":"Counterpart to the `member` check: `assertIn`/`assertNotIn` need a second, `container`, argument so the rewrite can emit `assert member in container`. When `args_map` has no `\"container\"` entry, `generate_assert` aborts with this error.","triggerScenarios":"`UnittestAssert::In | NotIn.generate_assert` where the call provided `member` but no second positional arg and no `container=` keyword — e.g. `self.assertIn(x)`.","commonSituations":"Half-finished `assertIn(x)` calls during test refactors; non-unittest helpers named `assertIn` mistaken for unittest methods by PT009.","solutions":["Supply the container: `self.assertIn(x, self.items)`.","Suppress PT009 for that file if the assert method is not unittest's.","When developing Ruff, note keyword lookup only fills names skipped positionally (`arg_spec.iter().skip(args.len())`); mismatched positional counts leave gaps.","Re-run the fixer after correcting the test code."],"exampleFix":"// before\nself.assertIn(item)\n// after\nself.assertIn(item, container)","handlingStrategy":"validation","validationCode":"def ensure_container(call_args, call_kwargs):\n    if len(call_args) < 2 and 'container' not in call_kwargs:\n        raise ValueError('assertIn requires (member, container)')","typeGuard":"def has_container(args: tuple, kwargs: dict) -> bool:\n    return len(args) >= 2 or 'container' in kwargs","tryCatchPattern":null,"preventionTips":["Always pass the container as the second argument of assertIn/assertNotIn.","Run `ruff check --no-fix` before enabling autofix in CI to spot incomplete calls.","Avoid refactors that delete the collection argument while keeping the assert call.","Use `assertIn(x, seq)` conventionally rather than keyword-only forms."],"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"}