Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flag-day: Auto-format and lint with black, isort, pylint and bandit + add to CI #439

Merged

Commits on Oct 20, 2022

  1. Update format-related config and requirements

    - Add black, isort, pylint and bandit to test requirements
    - Update indent in editorconfig to match black (4 spaces)
    - Add basic pylintrc file (copy-pasted from python-tuf)
    - gitignore pre-commit config
    
    Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
    lukpueh committed Oct 20, 2022
    Configuration menu
    Copy the full SHA
    52a0b6b View commit details
    Browse the repository at this point in the history
  2. Auto-format with black

    Used command:
      `black --line-length=80 --extend-exclude=_vendor .`
    
    Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
    lukpueh committed Oct 20, 2022
    Configuration menu
    Copy the full SHA
    8531f7d View commit details
    Browse the repository at this point in the history
  3. Auto-format with isort

    Used command:
      ```
      isort --line-length=80 --extend-skip-glob='*/_vendor' \
            --profile=black --project=securesystemslib .
      ```
    
    Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
    lukpueh committed Oct 20, 2022
    Configuration menu
    Copy the full SHA
    b48bc23 View commit details
    Browse the repository at this point in the history
  4. Ignore pylint non-error/fatal pylint issues inline

    Inline-disable all non-error/fatal pylint issues raised by running
    `pylint -j 0 --rcfile=pylintrc securesystemslib tests`, by adding
    inline comments a la `"# pylint: disable=<issue>[, ...]"`.
    
    This allows running pylint on future PRs without spending much
    effort on existing code, whose future is uncertain (see secure-systems-lab#270).
    
    The patch was created mostly automatically with this script:
    https://gist.github.com/lukpueh/41026a3a7a594164150faf5afce94774
    
    Unfortunately, both black and isort reformat inline comments in a
    way that pylint won't consider them anymore. Thus, some manual
    adjustments after running above script were necessary.
    https://black.readthedocs.io/en/stable/faq.html#why-does-my-linter-or-typechecker-complain-after-i-format-my-code
    
    Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
    lukpueh committed Oct 20, 2022
    Configuration menu
    Copy the full SHA
    91ac1f3 View commit details
    Browse the repository at this point in the history
  5. Fix pylint error E0102 (function-redefined)

    Remove outdated original function.
    
    Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
    lukpueh committed Oct 20, 2022
    Configuration menu
    Copy the full SHA
    32b654b View commit details
    Browse the repository at this point in the history
  6. Disable pylint error E1101 (no-member)

    This seems to be a false positive related to unpacking a tuple
    in a for loop.
    
    Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
    lukpueh committed Oct 20, 2022
    Configuration menu
    Copy the full SHA
    8bf06db View commit details
    Browse the repository at this point in the history
  7. Ignore low/medium-severity bandit issues inline

    Inline-disable low/medium-severity bandit issues raised by running
    `bandit --recursive securesystemslib --exclude _vendor`, by adding
    inline comments a la `"# nosec"`.
    
    This allows running bandit on future PRs without spending much
    effort on existing code, whose future is uncertain (see secure-systems-lab#270).
    
    Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
    lukpueh committed Oct 20, 2022
    Configuration menu
    Copy the full SHA
    5c2b1d2 View commit details
    Browse the repository at this point in the history
  8. Configure black, isort, pylint and bandit in CI

    - Add 'lint' tox environment that runs black, isort and bandit, and
      mypy (moved from its own env).
    - Run new tox env in ci GitHub Action.
    
    Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
    lukpueh committed Oct 20, 2022
    Configuration menu
    Copy the full SHA
    6ede7d6 View commit details
    Browse the repository at this point in the history
  9. List flag-day commits in .git-blame-ignore-revs

    For usage and details see:
    https://black.readthedocs.io/en/stable/guides/introducing_black_to_your_project.html
    
    Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
    lukpueh committed Oct 20, 2022
    Configuration menu
    Copy the full SHA
    b831bd2 View commit details
    Browse the repository at this point in the history