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

Re-enable lint for tests, remove usage of pylint #4921

Merged
merged 2 commits into from
Feb 24, 2018
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
6 changes: 6 additions & 0 deletions bigquery/.flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
[flake8]
exclude =
# Exclude generated code.
**/proto/**
**/gapic/**
*_pb2.py

# Standard linting exemptions.
__pycache__,
.git,
*.pyc,
Expand Down
9 changes: 1 addition & 8 deletions bigquery/nox.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,12 @@ def lint(session):
"""
session.interpreter = 'python3.6'

session.install('flake8', 'pylint', 'gcp-devrel-py-tools', *LOCAL_DEPS)
session.install('flake8')
session.install('.')
session.run('flake8', os.path.join('google', 'cloud', 'bigquery'))
session.run('flake8', 'tests')
session.run(
'flake8', os.path.join(os.pardir, 'docs', 'bigquery', 'snippets.py'))
session.run(
'gcp-devrel-py-tools', 'run-pylint',
'--config', 'pylint.config.py',
'--library-filesets', 'google',
'--test-filesets', 'tests',
# Temporarily allow this to fail.
success_codes=range(0, 100))


@nox.session
Expand Down
2 changes: 1 addition & 1 deletion bigquery_datatransfer/nox.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def default(session):
'py.test',
'--quiet',
'--cov=google.cloud.bigquery_datatransfer',
'--cov=google.cloud.bigquery_datatransfer_v1',
'--cov=google.cloud.bigquery_datatransfer_v1',
'--cov=tests.unit',
'--cov-append',
'--cov-config=.coveragerc',
Expand Down
7 changes: 4 additions & 3 deletions bigtable/.flake8
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[flake8]
exclude =
# BigTable includes generated code in the manual layer;
# do not lint this.
google/cloud/bigtable/_generated/*.py,
# Exclude generated code.
**/proto/**
**/gapic/**
*_pb2.py

# Standard linting exemptions.
__pycache__,
Expand Down
11 changes: 2 additions & 9 deletions bigtable/nox.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,9 @@ def lint(session):
serious code quality issues.
"""
session.interpreter = 'python3.6'
session.install('flake8', 'pylint', 'gcp-devrel-py-tools', *LOCAL_DEPS)
session.install('flake8')
session.install('.')
session.run('flake8', 'google/cloud/bigtable')
session.run(
'gcp-devrel-py-tools', 'run-pylint',
'--config', 'pylint.config.py',
'--library-filesets', 'google',
'--test-filesets', 'tests',
# Temporarily allow this to fail.
success_codes=range(0, 100))
session.run('flake8', 'google', 'tests')


@nox.session
Expand Down
6 changes: 3 additions & 3 deletions bigtable/tests/unit/test_row_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@


import unittest
import timeit
import csv


class TestCell(unittest.TestCase):
Expand Down Expand Up @@ -47,7 +45,8 @@ def _from_pb_test_helper(self, labels=None):
else:
cell_pb = data_v2_pb2.Cell(
value=value, timestamp_micros=timestamp_micros, labels=labels)
cell_expected = self._make_one(value, timestamp_micros, labels=labels)
cell_expected = self._make_one(
value, timestamp_micros, labels=labels)

klass = self._get_target_class()
result = klass.from_pb(cell_pb)
Expand Down Expand Up @@ -631,6 +630,7 @@ def test_empty_cell_chunk(self):
def test_empty_second_qualifier(self):
self._match_results('empty second qualifier')


def _flatten_cells(prd):
# Match results format from JSON testcases.
# Doesn't handle error cases.
Expand Down
33 changes: 16 additions & 17 deletions bigtable/tests/unit/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,6 @@ def test_callable_empty_rows(self):
self.assertEqual(len(statuses), 0)

def test_callable_no_retry_strategy(self):
from google.api_core.retry import Retry
from google.cloud.bigtable.row import DirectRow

# Setup:
Expand Down Expand Up @@ -685,7 +684,6 @@ def test_callable_no_retry_strategy(self):
self.assertEqual(result, expected_result)

def test_callable_retry(self):
from google.api_core.retry import Retry
from google.cloud.bigtable.row import DirectRow
from google.cloud.bigtable.table import DEFAULT_RETRY

Expand Down Expand Up @@ -735,7 +733,6 @@ def test_callable_retry(self):
self.assertEqual(result, expected_result)

def test_callable_retry_timeout(self):
from google.api_core.retry import Retry
from google.cloud.bigtable.row import DirectRow
from google.cloud.bigtable.table import DEFAULT_RETRY

Expand Down Expand Up @@ -811,8 +808,8 @@ def test_do_mutate_retryable_rows(self):
# Patch the stub used by the API method.
client._data_stub = _FakeStub([response])

worker = self._make_worker(table._instance._client,
table.name, [row_1, row_2])
worker = self._make_worker(
table._instance._client, table.name, [row_1, row_2])
statuses = worker._do_mutate_retryable_rows()

result = [status.code for status in statuses]
Expand Down Expand Up @@ -853,8 +850,8 @@ def test_do_mutate_retryable_rows_retry(self):
# Patch the stub used by the API method.
client._data_stub = _FakeStub([response])

worker = self._make_worker(table._instance._client,
table.name, [row_1, row_2, row_3])
worker = self._make_worker(
table._instance._client, table.name, [row_1, row_2, row_3])

with self.assertRaises(_BigtableRetryableError):
worker._do_mutate_retryable_rows()
Expand Down Expand Up @@ -902,8 +899,9 @@ def test_do_mutate_retryable_rows_second_retry(self):
# Patch the stub used by the API method.
client._data_stub = _FakeStub([response])

worker = self._make_worker(table._instance._client,
table.name, [row_1, row_2, row_3, row_4])
worker = self._make_worker(
table._instance._client,
table.name, [row_1, row_2, row_3, row_4])
worker.responses_statuses = self._make_responses_statuses([
self.SUCCESS,
self.RETRYABLE_1,
Expand Down Expand Up @@ -954,8 +952,9 @@ def test_do_mutate_retryable_rows_second_try(self):
# Patch the stub used by the API method.
client._data_stub = _FakeStub([response])

worker = self._make_worker(table._instance._client,
table.name, [row_1, row_2, row_3, row_4])
worker = self._make_worker(
table._instance._client,
table.name, [row_1, row_2, row_3, row_4])
worker.responses_statuses = self._make_responses_statuses([
self.SUCCESS,
self.RETRYABLE_1,
Expand All @@ -974,7 +973,6 @@ def test_do_mutate_retryable_rows_second_try(self):

def test_do_mutate_retryable_rows_second_try_no_retryable(self):
from google.cloud.bigtable.row import DirectRow
from tests.unit._testing import _FakeStub

# Setup:
# - Mutate 2 rows.
Expand All @@ -993,10 +991,10 @@ def test_do_mutate_retryable_rows_second_try_no_retryable(self):
row_2 = DirectRow(row_key=b'row_key_2', table=table)
row_2.set_cell('cf', b'col', b'value2')

worker = self._make_worker(table._instance._client,
table.name, [row_1, row_2])
worker = self._make_worker(
table._instance._client, table.name, [row_1, row_2])
worker.responses_statuses = self._make_responses_statuses(
[self.SUCCESS, self.NON_RETRYABLE])
[self.SUCCESS, self.NON_RETRYABLE])

statuses = worker._do_mutate_retryable_rows()

Expand All @@ -1023,8 +1021,9 @@ def test_do_mutate_retryable_rows_mismatch_num_responses(self):
# Patch the stub used by the API method.
client._data_stub = _FakeStub([response])

worker = self._make_worker(table._instance._client,
table.name, [row_1, row_2])
worker = self._make_worker(
table._instance._client,
table.name, [row_1, row_2])
with self.assertRaises(RuntimeError):
worker._do_mutate_retryable_rows()

Expand Down
2 changes: 1 addition & 1 deletion container/nox.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def default(session):
'py.test',
'--quiet',
'--cov=google.cloud.container',
'--cov=google.cloud.container_v1',
'--cov=google.cloud.container_v1',
'--cov=tests.unit',
'--cov-append',
'--cov-config=.coveragerc',
Expand Down
3 changes: 1 addition & 2 deletions core/nox.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ def lint(session):
serious code quality issues.
"""
session.interpreter = 'python3.6'
session.install(
'flake8', 'flake8-import-order', *LOCAL_DEPS)
session.install('flake8', 'flake8-import-order')
session.install('.')
session.run('flake8', 'google', 'tests')

Expand Down
2 changes: 1 addition & 1 deletion dataproc/nox.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def default(session):
'py.test',
'--quiet',
'--cov=google.cloud.dataproc',
'--cov=google.cloud.dataproc_v1',
'--cov=google.cloud.dataproc_v1',
'--cov=tests.unit',
'--cov-append',
'--cov-config=.coveragerc',
Expand Down
7 changes: 4 additions & 3 deletions datastore/.flake8
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[flake8]
exclude =
# Datastore includes generated code in the manual layer;
# do not lint this.
google/cloud/datastore/_app_engine_key_pb2.py,
# Exclude generated code.
**/proto/**
**/gapic/**
*_pb2.py

# Standard linting exemptions.
__pycache__,
Expand Down
11 changes: 2 additions & 9 deletions datastore/nox.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,9 @@ def lint(session):
serious code quality issues.
"""
session.interpreter = 'python3.6'
session.install('flake8', 'pylint', 'gcp-devrel-py-tools', *LOCAL_DEPS)
session.install('flake8')
session.install('.')
session.run('flake8', 'google/cloud/datastore')
session.run(
'gcp-devrel-py-tools', 'run-pylint',
'--config', 'pylint.config.py',
'--library-filesets', 'google',
'--test-filesets', 'tests',
# Temporarily allow this to fail.
success_codes=range(0, 100))
session.run('flake8', 'google', 'tests')


@nox.session
Expand Down
2 changes: 0 additions & 2 deletions datastore/tests/doctests.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

import six

import sphinx

from google.cloud import datastore


Expand Down
3 changes: 1 addition & 2 deletions datastore/tests/system/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from google.cloud._helpers import UTC
from google.cloud import datastore
from google.cloud.datastore.helpers import GeoPoint
from google.cloud.datastore_v1 import types
from google.cloud.environment_vars import GCD_DATASET
from google.cloud.exceptions import Conflict

Expand Down Expand Up @@ -366,7 +365,7 @@ def test_projection_query(self):

def test_query_paginate_simple(self):

# See issue #4264
# See issue #4264
page_query = self.CLIENT.query(kind='uuid_key')
iterator = page_query.fetch()

Expand Down
18 changes: 7 additions & 11 deletions datastore/tests/system/utils/populate_datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from __future__ import print_function

import os
import uuid

import six

Expand Down Expand Up @@ -103,25 +104,20 @@ def add_characters(client=None):
character['family']))


def add_uid_keys():
with self.CLIENT.batch() as batch:
for index in range(1000):
uid = str(uuid.uuid4())
key = self.CLIENT.key('uuid_key', uid)
entity = datastore.Entity(key=key)
batch.put(entity)

def add_uid_keys(client):
if client is None:
# Get a client that uses the test dataset.
client = datastore.Client()

def add_uid_keys():
num_batches = 2
batch_size = 500

keys = []
for batch_num in range(num_batches):
with self.CLIENT.batch() as batch:
with client.batch() as batch:
for seq_no in range(batch_size):
uid = str(uuid.uuid4())
key = self.CLIENT.key('uuid_key', uid)
key = client.key('uuid_key', uid)
keys.append(key)
entity = datastore.Entity(key=key)
entity['batch_num'] = batch_num
Expand Down
10 changes: 5 additions & 5 deletions datastore/tests/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,15 +935,15 @@ def test_transaction_defaults(self):
mock_klass.assert_called_once_with(client)

def test_read_only_transaction_defaults(self):
from google.cloud.datastore.transaction import Transaction
from google.cloud.datastore_v1.types import TransactionOptions
creds = _make_credentials()
client = self._make_one(credentials=creds)
xact = client.transaction(read_only=True)
self.assertEqual(xact._options,
TransactionOptions(
read_only=TransactionOptions.ReadOnly()
)
self.assertEqual(
xact._options,
TransactionOptions(
read_only=TransactionOptions.ReadOnly()
)
)
self.assertFalse(xact._options.HasField("read_write"))
self.assertTrue(xact._options.HasField("read_only"))
Expand Down
1 change: 0 additions & 1 deletion datastore/tests/unit/test_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ def test_id(self):
self.assertEqual(entity.id, _ID)

def test_id_none(self):
from google.cloud.datastore.key import Key

entity = self._make_one(key=None)
self.assertEqual(entity.id, None)
Expand Down
3 changes: 2 additions & 1 deletion datastore/tests/unit/test_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,8 @@ def test_two_pairs(self):
kind2 = 'child'
name2 = 'naem'

dict_path = [{'kind': kind1, 'id': id1}, {'kind': kind2, 'name': name2}]
dict_path = [
{'kind': kind1, 'id': id1}, {'kind': kind2, 'name': name2}]
path_pb = self._call_fut(dict_path)

element_pb1 = _make_element_pb(type=kind1, id=id1)
Expand Down
6 changes: 6 additions & 0 deletions dns/.flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
[flake8]
exclude =
# Exclude generated code.
**/proto/**
**/gapic/**
*_pb2.py

# Standard linting exemptions.
__pycache__,
.git,
*.pyc,
Expand Down
Loading