Skip to content

Ruff rule PLC0207 (and autofix) misses obvious rule propogation on chained splits #23105

@Skylion007

Description

@Skylion007

Summary

I ran ruff rule PLC0207 on Sympy sympy/printing/pycode.py and noticed while it was able to recognize that the last item should have maxsplit, it did not propogate the split to the earlier chained splits.

-            return fqn.split('(')[0].split('[')[0].split('.')[-1]
+            return fqn.split('(')[0].split('[')[0].rsplit('.', maxsplit=1)[-1]

it should be

-            return fqn.split('(')[0].split('[')[0].split('.')[-1]
+            return fqn.split('(', maxsplit=1)[0].split('[', maxsplit=1)[0].rsplit('.', maxsplit=1)[-1]

The rule acceptance settings should be relaxed slightly in this case. so that maxsplit can propogate to all the other values in the chained split.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions