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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ root = true

[*]
charset = utf-8
indent_size = 2
indent_size = 4
insert_final_newline = true
end_of_line = lf
indent_style = space
8 changes: 8 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Ignore black, isort and pylint (auto-disable)
#
# For change details see commit messages
# For usage see
# https://black.readthedocs.io/en/stable/guides/introducing_black_to_your_project.html
8531f7d8edc8732a959cf283e64b0d19b49f7a16
b48bc23acc7e49cdd1029d207ef61deca45c100d
91ac1f3154cea57e1bf1a8bebd368fce5b07176c
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
toxenv: py38-no-gpg
- python-version: 3.8
os: ubuntu-latest
toxenv: mypy
toxenv: lint

runs-on: ${{ matrix.os }}

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ env/*
tests/htmlcov/*
.DS_Store
.python-version
.pre-commit-config.yaml
50 changes: 50 additions & 0 deletions pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Pylint section

# Minimal pylint configuration file for Secure Systems Lab Python Style Guide:
# https://github.com/secure-systems-lab/code-style-guidelines
#
# Based on Google Python Style Guide pylintrc and pylint defaults:
# https://google.github.io/styleguide/pylintrc
# http://pylint.pycqa.org/en/latest/technical_reference/features.html
[MASTER]
ignore = _vendor

[message_control]
# Disable the message, report, category or checker with the given id(s).
# NOTE: To keep this config as short as possible we only disable checks that
# are currently in conflict with our code. If new code displeases the linter
# (for good reasons) consider updating this config file, or disable checks with.
disable =
fixme,
too-few-public-methods,
too-many-arguments,
format,
duplicate-code

[basic]
good-names = i,j,k,v,e,f,fn,fp,_type,_
# Regexes for allowed names are copied from the Google pylintrc
# NOTE: Pylint captures regex name groups such as 'snake_case' or 'camel_case'.
# If there are multiple groups it enfoces the prevalent naming style inside
# each modules. Names in the exempt capturing group are ignored.
function-rgx = ^(?:(?P<exempt>setUp|tearDown|setUpModule|tearDownModule)|(?P<camel_case>_?[A-Z][a-zA-Z0-9]*)|(?P<snake_case>_?[a-z][a-z0-9_]*))$
method-rgx = (?x)^(?:(?P<exempt>_[a-z0-9_]+__|runTest|setUp|tearDown|setUpTestCase|tearDownTestCase|setupSelf|tearDownClass|setUpClass|(test|assert)_*[A-Z0-9][a-zA-Z0-9_]*|next)|(?P<camel_case>_{0,2}[A-Z][a-zA-Z0-9_]*)|(?P<snake_case>_{0,2}[a-z][a-z0-9_]*))$
argument-rgx = ^[a-z][a-z0-9_]*$
attr-rgx = ^_{0,2}[a-z][a-z0-9_]*$
class-attribute-rgx = ^(_?[A-Z][A-Z0-9_]*|__[a-z0-9_]+__|_?[a-z][a-z0-9_]*)$
class-rgx = ^_?[A-Z][a-zA-Z0-9]*$
const-rgx = ^(_?[A-Z][A-Z0-9_]*|__[a-z0-9_]+__|_?[a-z][a-z0-9_]*)$
inlinevar-rgx = ^[a-z][a-z0-9_]*$
module-rgx = ^(_?[a-z][a-z0-9_]*|__init__)$
no-docstring-rgx = (__.*__|main|test.*|.*test|.*Test)$
variable-rgx = ^[a-z][a-z0-9_]*$
docstring-min-length = 10

[logging]
logging-format-style=old

[miscellaneous]
notes=TODO

[STRING]
check-quote-consistency=yes
6 changes: 5 additions & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# additional test tools
coverage
mypy
mypy
black
isort
pylint
bandit
1 change: 1 addition & 0 deletions securesystemslib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint: disable=missing-module-docstring
import logging

# Configure a basic 'securesystemslib' top-level logger with a StreamHandler
Expand Down
Loading