Whole file

bwhmather/ssort

The author described this change as Fix detection of self argument name when positional-only. It counts as a record because the check below fails on the code as it stood at 3d87560a6 and passes on e5890c885, with nothing else changed between the two runs.

Fix saved2024-01-18
Sharing licenceMIT · LICENSE
Change size+5 3

What the code was meant to do, written into the code itself as a save note

Fix detection of self argument name when positional-only

The change

4444 def _get_method_requirements_for_function_def(
4545 node: ast.FunctionDef | ast.AsyncFunctionDef,
4646 ) -> Iterable[str]:
47- if not node.args.args:
47+ if node.args.posonlyargs:
48+ self_arg = node.args.posonlyargs[0].arg
49+ elif node.args.args:
50+ self_arg = node.args.args[0].arg
51+ else:
4852 return
49-
50- self_arg = node.args.args[0].arg
5153
5254 for statement in node.body:
5355 yield from _get_attribute_accesses(statement, self_arg)

The check that tells the two apart

failpass·tests/test_method_requirements.py::test_method_requirements_positional_only_self

Check file tests/test_method_requirements.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it3d87560a666575310125f46a3be39194a26ade53
Broken version dated2024-01-18
Modulessort._method_requirements
Units changed_get_method_requirements_for_function_def
Fingerprint7b87a47a575d38ce
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in bwhmather/ssort