Skip to content

Commit 777218d

Browse files
author
Takashi Matsuo
authored
chore: some lint fixes (#3749)
1 parent 0995cc1 commit 777218d

File tree

14 files changed

+48
-29
lines changed

14 files changed

+48
-29
lines changed

run/image-processing/main.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@
1414

1515
# [START run_imageproc_controller]
1616
import base64
17-
from flask import Flask, request
1817
import json
1918
import os
2019
import sys
20+
21+
from flask import Flask, request
22+
2123
import image
2224

25+
2326
app = Flask(__name__)
2427

2528

run/image-processing/main_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414

1515
# NOTE:
1616
# These tests are unit tests that mock Pub/Sub.
17-
1817
import base64
1918
import json
20-
import main
19+
import uuid
20+
2121
import mock
2222
import pytest
2323

24-
from uuid import uuid4
24+
import main
2525

2626

2727
@pytest.fixture
@@ -55,8 +55,8 @@ def test_minimally_valid_message(client):
5555

5656

5757
def test_call_to_blur_image(client, capsys):
58-
filename = str(uuid4())
59-
blur_bucket = 'blurred-bucket-' + str(uuid4())
58+
filename = str(uuid.uuid4())
59+
blur_bucket = 'blurred-bucket-' + str(uuid.uuid4())
6060

6161
data_json = json.dumps({'name': filename, 'bucket': blur_bucket})
6262
data = base64.b64encode(data_json.encode()).decode()

run/logging-manual/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from flask import Flask, request
1615
import json
1716
import os
1817
import sys
1918

19+
from flask import Flask, request
20+
21+
2022
app = Flask(__name__)
2123

2224

run/logging-manual/main_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
# NOTE:
1616
# These unit tests mock logging.
1717

18-
1918
import pytest
19+
2020
import main
2121

2222

run/markdown-preview/editor/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from flask import Flask, render_template, request
1615
import os
1716

17+
from flask import Flask, render_template, request
18+
1819
import render
1920

21+
2022
app = Flask(__name__)
2123

2224

run/markdown-preview/editor/main_test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import main
16-
import os
1715
import json
16+
import os
17+
1818
import pytest
1919

20+
import main # noqa I100 for parent lint
21+
2022

2123
@pytest.fixture
2224
def client():

run/markdown-preview/noxfile.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@
3434
#
3535

3636

37-
# Ignore I202 "Additional newline in a section of imports." to accommodate
38-
# region tags in import blocks. Since we specify an explicit ignore, we also
39-
# have to explicitly ignore the list of default ignores:
40-
# `E121,E123,E126,E226,E24,E704,W503,W504` as shown by `flake8 --help`.
4137
def _determine_local_import_names(start_dir):
4238
"""Determines all import names that should be considered "local".
4339
@@ -54,13 +50,23 @@ def _determine_local_import_names(start_dir):
5450
]
5551

5652

53+
# Linting with flake8.
54+
#
55+
# We ignore the following rules:
56+
# E203: whitespace before ‘:’
57+
# E266: too many leading ‘#’ for block comment
58+
# E501: line too long
59+
# I202: Additional newline in a section of imports
60+
#
61+
# We also need to specify the rules which are ignored by default:
62+
# ['E226', 'W504', 'E126', 'E123', 'W503', 'E24', 'E704', 'E121']
5763
FLAKE8_COMMON_ARGS = [
5864
"--show-source",
5965
"--builtin=gettext",
6066
"--max-complexity=20",
6167
"--import-order-style=google",
6268
"--exclude=.nox,.cache,env,lib,generated_pb2,*_pb2.py,*_pb2_grpc.py",
63-
"--ignore=E121,E123,E126,E203,E226,E24,E266,E501,E704,W503,W504,I100,I201,I202",
69+
"--ignore=E121,E123,E126,E203,E226,E24,E266,E501,E704,W503,W504,I202",
6470
"--max-line-length=88",
6571
]
6672

run/markdown-preview/renderer/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import os
16+
1517
import bleach
1618
from flask import Flask, request
1719
import markdown
18-
import os
1920

2021

2122
app = Flask(__name__)

run/markdown-preview/renderer/main_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import main
1615
import pytest
1716

17+
import main # noqa I100 for parent lint
18+
1819

1920
@pytest.fixture
2021
def client():

run/pubsub/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414

1515
# [START run_pubsub_server_setup]
1616
import base64
17-
from flask import Flask, request
1817
import os
1918
import sys
2019

20+
from flask import Flask, request
21+
22+
2123
app = Flask(__name__)
2224
# [END run_pubsub_server_setup]
2325

run/system-package/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from flask import Flask, make_response, request
1615
import os
1716
import subprocess
1817
import sys
1918

19+
from flask import Flask, make_response, request
20+
2021

2122
app = Flask(__name__)
2223

run/system-package/main_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414

1515
# NOTE:
1616
# To pass these tests locally, run `brew install graphviz`
17-
17+
import pytest
1818

1919
import main
20-
import pytest
2120

2221

2322
@pytest.fixture

secretmanager/api-client/snippets_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313

1414
import os
15-
import pytest
1615
import uuid
1716

18-
from quickstart import quickstart
17+
from google.api_core import exceptions
18+
from google.cloud import secretmanager
19+
import pytest
20+
1921
from access_secret_version import access_secret_version
2022
from add_secret_version import add_secret_version
2123
from create_secret import create_secret
@@ -29,11 +31,9 @@
2931
from iam_revoke_access import iam_revoke_access
3032
from list_secret_versions import list_secret_versions
3133
from list_secrets import list_secrets
34+
from quickstart import quickstart
3235
from update_secret import update_secret
3336

34-
from google.api_core import exceptions
35-
from google.cloud import secretmanager
36-
3737

3838
@pytest.fixture()
3939
def client():

spanner/cloud-client/backup_sample_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
import random
15+
import string
1416

1517
from google.cloud import spanner
1618
import pytest
17-
import random
18-
import string
1919

2020
import backup_sample
2121

0 commit comments

Comments
 (0)