Lint with flake8#9958
Conversation
Uses flake8-tabs so that we can use tab rather than spaces. Includes a default config file for flake8 (flake8.ini) Scons build targets added: lint: Produces a unified diff (against HEAD), and runs flake8 linter against this diff. lintInstall: Uses pip (and a requirements file) to install flake8 dependency. A file test.py is included as a demonstration, this will be removed prior to merging.
Test result must be converted to junit compatible xml.
We do a shallow clone when initially fetching the repo, so we need to get the base branch as well now.
LeonarddeR
left a comment
There was a problem hiding this comment.
I'm aware of this still being a draft, but I'm pretty interested to see this finished.
|
I have the following suggestions for the configuration of flake8:
|
|
|
@feerrenrut commented on 24 Jul 2019, 19:31 CEST:
Ah, I had hoped that it was more descriptive. Never mind. |
…se argument. There might be a better way to do this. It would be nice if arguments were tied to sub scripts.
Errors should not be raised for adjacent code.
Also send a message when linting fails.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
PR introduces Flake8 errors 😲 See test results for Failed build of commit 02b3346201 |
Co-Authored-By: Leonard de Ruijter <leonardder@users.noreply.github.com>
Co-Authored-By: Leonard de Ruijter <leonardder@users.noreply.github.com>
|
PR introduces Flake8 errors 😲 See test results for Failed build of commit 0def0c5900 |
|
Testing with flake8 within VS Code reveals that it raises warnings for using |
|
Are you using the config file from this PR? |
|
Ah I'm sorr, turns out that I was using an out of date version of the branch for my testing purposes. |
|
PR introduces Flake8 errors 😲 See test results for Failed build of commit dfe787d60b |
|
PR introduces Flake8 errors 😲 See test results for Failed build of commit 931f1598d7 |
Remove --disable-noqa Remove test.py full of # noqa: comments
W503 is: line break before binary operator. Contrasted with W504: line break after binary operator, which we want to check for.
LeonarddeR
left a comment
There was a problem hiding this comment.
I think it would be good to remove source/pylintrc while at it. According to @bramd, it has its issues anyway.
| # This file is covered by the GNU General Public License. | ||
| # See the file COPYING for more details. | ||
| # Copyright (C) 2019 NV Access Limited | ||
| import os |
There was a problem hiding this comment.
Could you add an empty line above this line?
Allow automatic changes to minor versions. Co-Authored-By: Leonard de Ruijter <leonardder@users.noreply.github.com>
|
Note that the base of this is still threshold. |
Thanks 👍 |
|
Hi, Coming back to this, I think it would be helpful to exclude checks for visual indents; although useful, it has drawbacks:
I'll create a new issue to discuss these further. Thanks. |
|
@josephsl we have a few issues to work through with the indentation checks, but I would really like it if we can find an acceptable configuration. This will likely require people to think about the configuration of their tools. |
|
Hi, right. Personally I can deal with indents quite easily thanks to Notepad++, but I imagine others may run into issues (older versions of Notepad, for example). Thanks.
|
|
This pr breaks publishing of NVDA releases on our server. I was able to work around this for beta1, but this certainly needs to be addressed for the final release. |
Link to issue number:
Closes #5918
Summary of the issue:
Code contributors regularly have to deal with ill-defined and inconsistently enforced code style requirements. Code reviewers spend much of their time reporting minor issues, time that would be better spent looking for architectural problems / product issues / logic errors.
Description of how this pull request fixes the issue:
Automate checking python style. The diff from new PR's will be tested for compliance with Flake8. The NVDA Python code already contains several inconsistent styles, so rather than try to match it I have tried to configure Flake8 to use the default style guidelines as much as possible.
This pr introduces two new SCons build targets:
lintgit diff -U0 $(git merge-base <baseBranch>)tests\lint\genDiff.py)flake8to perform the linting.tests/lint/current.lintlintInstalllint.requirements.txtfile.AppVeyor:
on_finishphase rather thanartifactsphase.Testing performed:
Tested locally:
#noqa: <code>comments work to suppress errors.Tested on appveyor:
flake8.lint.flake8_diff_linton https://ci.appveyor.com/project/NVAccess/nvda/builds/26350748/testsKnown issues with pull request:
--disable-noqato demonstrate test file, needs removallintInstallgitin path.Change log entry:
Changes for developers:
- Flake8 linting tool has been integrated with SCons reflecting code requirements for Pull Requests. (#5918)