Closed Bug 1388721 Opened 4 years ago Closed 3 years ago

[flake8] Support --fix in the flake8 linter

Categories

(Firefox Build System :: Lint and Formatting, enhancement, P3)

enhancement

Tracking

(firefox62 fixed)

RESOLVED FIXED
mozilla62
Tracking Status
firefox62 --- fixed

People

(Reporter: ahal, Assigned: ahal)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Flake8 itself doesn't fix errors, but we can install the autopep8 module to handle the pycodestyle problems.

We'll need to figure out a way to get them both to use the same configuration files. This might depend on being a bit smarter with flake8 configs.
Severity: normal → enhancement
Priority: -- → P3
Product: Testing → Firefox Build System
Assignee: nobody → ahal
Status: NEW → ASSIGNED
Comment on attachment 8981137 [details]
Bug 1388721 - [lint] Support --fix in the flake8 linter via autopep8,

https://reviewboard.mozilla.org/r/246956/#review253312

::: tools/lint/python/flake8.py:131
(Diff revision 1)
>                      '"column":%(col)s,"rule":"%(code)s","message":"%(text)s"}',
>      ]
>  
> +    fix_cmdargs = [
> +        os.path.join(bindir, 'autopep8'),
> +        '--global-config', os.path.join(lintargs['root'], '.flake8'),

This is going to take in account the max length = 99, right ?

::: tools/lint/test/test_flake8.py:43
(Diff revision 1)
> +
> +    results = lint([path.strpath])
> +    assert len(results) == 2
> +
> +    # Make sure the missing blank line is fixed, but the unused import isn't.
> +    results = lint([path.strpath], fix=True)

Maybe you could also add a test with path = a directory?
Comment on attachment 8981137 [details]
Bug 1388721 - [lint] Support --fix in the flake8 linter via autopep8,

https://reviewboard.mozilla.org/r/246956/#review253312

> This is going to take in account the max length = 99, right ?

Yes, that's defined in the global topsrcdir/.flake8 config which this uses. Guess I can add a test just to make sure.
Comment on attachment 8981137 [details]
Bug 1388721 - [lint] Support --fix in the flake8 linter via autopep8,

https://reviewboard.mozilla.org/r/246956/#review253342

Great, thanks!

By the way; I fixed more components, I will push them asap
Attachment #8981137 - Flags: review?(sledru) → review+
Pushed by ahalberstadt@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/be2690ae5c76
[lint] Support --fix in the flake8 linter via autopep8, r=sylvestre
https://hg.mozilla.org/mozilla-central/rev/be2690ae5c76
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla62
Depends on: 1611088
Blocks: 1611152
You need to log in before you can comment on or make changes to this bug.