tinypilot icon indicating copy to clipboard operation
tinypilot copied to clipboard

Revisit pylint directives to narrow their scope?

Open jotaen4tinypilot opened this issue 2 years ago • 0 comments

For some tests, we provide custom assert methods, like here for example.

    # pylint: disable=invalid-name
    def assertKeystrokesEqual(self, expected, actual):
        if expected != actual:
            raise AssertionError('%s != %s' % (expected, actual))

Problem is, the pylint directive applies to the entire class body, however, not just for the subsequent line of code. So with the example above, all subsequent functions are exempted from the regular naming rule.

If we wanted to narrow the scope, one option would be to put the directive at the end of the offending line:

    def assertKeystrokesEqual(self, expected, actual):  # pylint: disable=invalid-name
        if expected != actual:
            raise AssertionError('%s != %s' % (expected, actual))

Downside is, that exceeds the 80 character limit that we have. (I think the linter doesn’t complain about that, though, so it’s only a stylistic issue.)

jotaen4tinypilot avatar Mar 03 '22 14:03 jotaen4tinypilot