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

Add python linter (flake8) to workflow and fix all files #25193

Closed
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
[flake8]
max-line-length = 132
exclude = third_party
.*
out/*
scripts/idl/*
./examples/common/QRCode/*
6 changes: 6 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,9 @@ jobs:
if: always()
run: |
git grep -n 'emberAfWriteAttribute' -- './*' ':(exclude).github/workflows/lint.yml' ':(exclude)src/app/util/af.h' ':(exclude)zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp' ':(exclude)src/app/zap-templates/templates/app/attributes/Accessors-src.zapt' ':(exclude)src/app/util/attribute-table.cpp' ':(exclude)examples/common/pigweed/rpc_services/Attributes.h' ':(exclude)src/app/util/attribute-table.h' ':(exclude)src/app/util/ember-compatibility-functions.cpp' && exit 1 || exit 0

# Run python Linter (flake8) and verify python files
- name: Check for errors using flake8 Python linter
if: always()
run: |
flake8 --extend-ignore=E501,W391
1 change: 0 additions & 1 deletion build/chip/java/tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import json
import os
import subprocess
import unittest
from os import path

Expand Down
4 changes: 2 additions & 2 deletions build/chip/linux/gen_gdbus_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ def main(argv):
] + extra_args + [options.input_file]
subprocess.check_call(gdbus_args)
sed_args = ["sed", "-i",
"s/config\.h/BuildConfig.h/g", options.output_c]
r"s/config\.h/BuildConfig.h/g", options.output_c]
if sys.platform == "darwin":
sed_args = ["sed", "-i", "",
"s/config\.h/BuildConfig.h/g", options.output_c]
r"s/config\.h/BuildConfig.h/g", options.output_c]
subprocess.check_call(sed_args)

if options.output_h:
Expand Down
4 changes: 2 additions & 2 deletions build/config/linux/pkg-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def MatchesAnyRegexp(flag, list_of_regexps):
"""Returns true if the first argument matches any regular expression in the
given list."""
for regexp in list_of_regexps:
if regexp.search(flag) != None:
if regexp.search(flag) is not None:
return True
return False

Expand Down Expand Up @@ -145,7 +145,7 @@ def main():

# Make a list of regular expressions to strip out.
strip_out = []
if options.strip_out != None:
if options.strip_out is not None:
for regexp in options.strip_out:
strip_out.append(re.compile(regexp))

Expand Down
19 changes: 12 additions & 7 deletions credentials/fetch-paa-certs-from-dcl.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import re
import subprocess
import sys
from contextlib import nullcontext

import click
import requests
Expand Down Expand Up @@ -123,12 +122,17 @@ def use_dcld(dcld, production, cmdlist):
@click.command()
@click.help_option('-h', '--help')
@optgroup.group('Input data sources', cls=RequiredMutuallyExclusiveOptionGroup)
@optgroup.option('--use-main-net-dcld', type=str, default='', metavar='PATH', help="Location of `dcld` binary, to use `dcld` for mirroring MainNet.")
@optgroup.option('--use-test-net-dcld', type=str, default='', metavar='PATH', help="Location of `dcld` binary, to use `dcld` for mirroring TestNet.")
@optgroup.option('--use-main-net-http', is_flag=True, type=str, help="Use RESTful API with HTTPS against public MainNet observer.")
@optgroup.option('--use-test-net-http', is_flag=True, type=str, help="Use RESTful API with HTTPS against public TestNet observer.")
@optgroup.option('--use-main-net-dcld', type=str, default='', metavar='PATH',
help="Location of `dcld` binary, to use `dcld` for mirroring MainNet.")
@optgroup.option('--use-test-net-dcld', type=str, default='', metavar='PATH',
help="Location of `dcld` binary, to use `dcld` for mirroring TestNet.")
@optgroup.option('--use-main-net-http', is_flag=True, type=str,
help="Use RESTful API with HTTPS against public MainNet observer.")
@optgroup.option('--use-test-net-http', is_flag=True, type=str,
help="Use RESTful API with HTTPS against public TestNet observer.")
@optgroup.group('Optional arguments')
@optgroup.option('--paa-trust-store-path', default='paa-root-certs', type=str, metavar='PATH', help="PAA trust store path (default: paa-root-certs)")
@optgroup.option('--paa-trust-store-path', default='paa-root-certs', type=str, metavar='PATH',
help="PAA trust store path (default: paa-root-certs)")
def main(use_main_net_dcld, use_test_net_dcld, use_main_net_http, use_test_net_http, paa_trust_store_path):
"""DCL PAA mirroring tools"""

Expand Down Expand Up @@ -163,7 +167,8 @@ def main(use_main_net_dcld, use_test_net_dcld, use_main_net_http, use_test_net_h

if use_rest:
response = requests.get(
f"{rest_node_url}/dcl/pki/certificates/{paa['subject']}/{paa['subjectKeyId']}").json()["approvedCertificates"]["certs"][0]
f"{rest_node_url}/dcl/pki/certificates/"
f"{paa['subject']}/{paa['subjectKeyId']}").json()["approvedCertificates"]["certs"][0]
certificate = response["pemCert"]
subject = response["subjectAsText"]
else:
Expand Down
2 changes: 1 addition & 1 deletion docs/_extensions/external_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def adjust_includes(

def _adjust_path(path):
# ignore absolute paths, section links, hyperlinks and same folder
if path.startswith(("/", "#", "http", "www")) or not "/" in path:
if path.startswith(("/", "#", "http", "www")) or "/" not in path:
return path

# for files that are being copied modify reference to and out of /docs
Expand Down
Loading