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

chore: some lint fixes #3749

Merged
merged 1 commit into from
May 13, 2020
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
5 changes: 4 additions & 1 deletion run/image-processing/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@

# [START run_imageproc_controller]
import base64
from flask import Flask, request
import json
import os
import sys

from flask import Flask, request

import image


app = Flask(__name__)


Expand Down
10 changes: 5 additions & 5 deletions run/image-processing/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

# NOTE:
# These tests are unit tests that mock Pub/Sub.

import base64
import json
import main
import uuid

import mock
import pytest

from uuid import uuid4
import main


@pytest.fixture
Expand Down Expand Up @@ -55,8 +55,8 @@ def test_minimally_valid_message(client):


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

data_json = json.dumps({'name': filename, 'bucket': blur_bucket})
data = base64.b64encode(data_json.encode()).decode()
Expand Down
4 changes: 3 additions & 1 deletion run/logging-manual/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from flask import Flask, request
import json
import os
import sys

from flask import Flask, request


app = Flask(__name__)


Expand Down
2 changes: 1 addition & 1 deletion run/logging-manual/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# NOTE:
# These unit tests mock logging.


import pytest

import main


Expand Down
4 changes: 3 additions & 1 deletion run/markdown-preview/editor/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from flask import Flask, render_template, request
import os

from flask import Flask, render_template, request

import render


app = Flask(__name__)


Expand Down
6 changes: 4 additions & 2 deletions run/markdown-preview/editor/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import main
import os
import json
import os

import pytest

import main # noqa I100 for parent lint


@pytest.fixture
def client():
Expand Down
16 changes: 11 additions & 5 deletions run/markdown-preview/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@
#


# Ignore I202 "Additional newline in a section of imports." to accommodate
# region tags in import blocks. Since we specify an explicit ignore, we also
# have to explicitly ignore the list of default ignores:
# `E121,E123,E126,E226,E24,E704,W503,W504` as shown by `flake8 --help`.
def _determine_local_import_names(start_dir):
"""Determines all import names that should be considered "local".

Expand All @@ -54,13 +50,23 @@ def _determine_local_import_names(start_dir):
]


# Linting with flake8.
#
# We ignore the following rules:
# E203: whitespace before ‘:’
# E266: too many leading ‘#’ for block comment
# E501: line too long
# I202: Additional newline in a section of imports
#
# We also need to specify the rules which are ignored by default:
# ['E226', 'W504', 'E126', 'E123', 'W503', 'E24', 'E704', 'E121']
FLAKE8_COMMON_ARGS = [
"--show-source",
"--builtin=gettext",
"--max-complexity=20",
"--import-order-style=google",
"--exclude=.nox,.cache,env,lib,generated_pb2,*_pb2.py,*_pb2_grpc.py",
"--ignore=E121,E123,E126,E203,E226,E24,E266,E501,E704,W503,W504,I100,I201,I202",
"--ignore=E121,E123,E126,E203,E226,E24,E266,E501,E704,W503,W504,I202",
"--max-line-length=88",
]

Expand Down
3 changes: 2 additions & 1 deletion run/markdown-preview/renderer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os

import bleach
from flask import Flask, request
import markdown
import os


app = Flask(__name__)
Expand Down
3 changes: 2 additions & 1 deletion run/markdown-preview/renderer/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import main
import pytest

import main # noqa I100 for parent lint


@pytest.fixture
def client():
Expand Down
4 changes: 3 additions & 1 deletion run/pubsub/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@

# [START run_pubsub_server_setup]
import base64
from flask import Flask, request
import os
import sys

from flask import Flask, request


app = Flask(__name__)
# [END run_pubsub_server_setup]

Expand Down
3 changes: 2 additions & 1 deletion run/system-package/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from flask import Flask, make_response, request
import os
import subprocess
import sys

from flask import Flask, make_response, request


app = Flask(__name__)

Expand Down
3 changes: 1 addition & 2 deletions run/system-package/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@

# NOTE:
# To pass these tests locally, run `brew install graphviz`

import pytest

import main
import pytest


@pytest.fixture
Expand Down
10 changes: 5 additions & 5 deletions secretmanager/api-client/snippets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
# See the License for the specific language governing permissions and

import os
import pytest
import uuid

from quickstart import quickstart
from google.api_core import exceptions
from google.cloud import secretmanager
import pytest

from access_secret_version import access_secret_version
from add_secret_version import add_secret_version
from create_secret import create_secret
Expand All @@ -29,11 +31,9 @@
from iam_revoke_access import iam_revoke_access
from list_secret_versions import list_secret_versions
from list_secrets import list_secrets
from quickstart import quickstart
from update_secret import update_secret

from google.api_core import exceptions
from google.cloud import secretmanager


@pytest.fixture()
def client():
Expand Down
4 changes: 2 additions & 2 deletions spanner/cloud-client/backup_sample_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import random
import string

from google.cloud import spanner
import pytest
import random
import string

import backup_sample

Expand Down