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.
Projectbwhmather/ssort
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
| 44 | 44 | def _get_method_requirements_for_function_def( | |
| 45 | 45 | node: ast.FunctionDef | ast.AsyncFunctionDef, | |
| 46 | 46 | ) -> 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: | |
| 48 | 52 | return | |
| 49 | - | ||
| 50 | - | self_arg = node.args.args[0].arg | |
| 51 | 53 | ||
| 52 | 54 | for statement in node.body: | |
| 53 | 55 | yield from _get_attribute_accesses(statement, self_arg) |
The check that tells the two apart
fail→pass·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
- 2026-08-03Fix handling of nested classes
- 2022-07-22Fix lambda requirements with walrus operator
- 2021-08-08_get_bindings_for_named_expr
- 2021-04-06_get_bindings_for_import
- 2021-04-06_get_bindings_for_with
- 2021-03-29Fix dependencies being return for bindings in comprehensions