astral-sh/ruff · error
Missing argument `member`
Error message
Missing argument `member`
What it means
`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.
Source
Thrown at crates/ruff_linter/src/rules/flake8_pytest_style/rules/unittest_assert.rs:347
| UnittestAssert::FailUnlessEqual => CmpOp::Eq,
UnittestAssert::NotEqual
| UnittestAssert::NotEquals
| UnittestAssert::FailIfEqual => CmpOp::NotEq,
UnittestAssert::Greater => CmpOp::Gt,
UnittestAssert::GreaterEqual => CmpOp::GtE,
UnittestAssert::Less => CmpOp::Lt,
UnittestAssert::LessEqual => CmpOp::LtE,
UnittestAssert::Is => CmpOp::Is,
UnittestAssert::IsNot => CmpOp::IsNot,
_ => unreachable!(),
};
let expr = compare(first, cmp_op, second);
Ok(assert(&expr, msg))
}
UnittestAssert::In | UnittestAssert::NotIn => {
let member = args
.get("member")
.ok_or_else(|| anyhow!("Missing argument `member`"))?;
let container = args
.get("container")
.ok_or_else(|| anyhow!("Missing argument `container`"))?;
let msg = args.get("msg").copied();
let cmp_op = if matches!(self, UnittestAssert::In) {
CmpOp::In
} else {
CmpOp::NotIn
};
let expr = compare(member, cmp_op, container);
Ok(assert(&expr, msg))
}
UnittestAssert::IsNone | UnittestAssert::IsNotNone => {
let expr = args
.get("expr")
.ok_or_else(|| anyhow!("Missing argument `expr`"))?;
let msg = args.get("msg").copied();
let cmp_op = if matches!(self, UnittestAssert::IsNone) {View on GitHub (pinned to 15f3fe6b15)
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.
Example fix
// before
self.assertIn(key='k', container=d)
// after
self.assertIn('k', d) Defensive patterns
Strategy: validation
Validate before calling
def valid_assert_in(call_args, call_kwargs):
return len(call_args) >= 1 or 'member' in call_kwargs Type guard
def is_membership_assert(args: tuple, kwargs: dict) -> bool:
return (len(args) >= 1 or 'member' in kwargs) and (len(args) >= 2 or 'container' in kwargs) Prevention
- 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.
When it happens
Trigger: `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).
Common situations: Incomplete `assertIn()` calls in suites being bulk-fixed with PT009; dynamically defined methods named `assertIn` on non-unittest classes with different signatures.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Missing argument `first`
- Missing argument `second`
- Missing argument `container`
- Missing argument `obj`
- Missing argument `cls`
AI-assisted analysis of astral-sh/ruff@15f3fe6b15 (2026-09-05).
Data as JSON: /api/errors/20ac082c8fb266cb.
Report an issue: GitHub.