Skip to content

Commit 0c874a4

Browse files
Ark-kuncopybara-github
authored andcommitted
chore: Fixed all linting issues and enabled linting in vertexai
PiperOrigin-RevId: 638919820
1 parent af1ead8 commit 0c874a4

File tree

8 files changed

+10
-24
lines changed

8 files changed

+10
-24
lines changed

noxfile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def lint(session):
9595
"--diff",
9696
*LINT_PATHS,
9797
)
98-
session.run("flake8", "google", "tests")
98+
session.run("flake8", *LINT_PATHS)
9999

100100

101101
@nox.session(python=DEFAULT_PYTHON_VERSION)
@@ -225,7 +225,7 @@ def unit_ray(session, ray):
225225
def unit_langchain(session):
226226
# Install all test dependencies, then install this package in-place.
227227

228-
constraints_path = str(CURRENT_DIRECTORY / "testing" / f"constraints-langchain.txt")
228+
constraints_path = str(CURRENT_DIRECTORY / "testing" / "constraints-langchain.txt")
229229
standard_deps = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_DEPENDENCIES
230230
session.install(*standard_deps, "-c", constraints_path)
231231

@@ -236,7 +236,7 @@ def unit_langchain(session):
236236
session.run(
237237
"py.test",
238238
"--quiet",
239-
f"--junitxml=unit_langchain_sponge_log.xml",
239+
"--junitxml=unit_langchain_sponge_log.xml",
240240
"--cov=google",
241241
"--cov-append",
242242
"--cov-config=.coveragerc",

tests/unit/vertexai/test_extensions.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,7 @@ def execute_extension_mock():
176176
with mock.patch.object(
177177
extension_execution_service.ExtensionExecutionServiceClient, "execute_extension"
178178
) as execute_extension_mock:
179-
response_mock = mock.MagicMock()
180-
response_mock.content.return_value = _TEST_RESPONSE_CONTENT
181-
api_client_mock = mock.MagicMock()
182-
api_client_mock.execute_extension.return_value = response_mock
183-
execute_extension_mock.return_value = api_client_mock
179+
execute_extension_mock.return_value.content = _TEST_RESPONSE_CONTENT
184180
yield execute_extension_mock
185181

186182

vertexai/_model_garden/_model_garden_models.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
from google.cloud.aiplatform import models as aiplatform_models
2626
from google.cloud.aiplatform import _publisher_models
2727

28-
# this is needed for class registration to _SUBCLASSES
29-
import vertexai # pylint:disable=unused-import
30-
3128
_SUPPORTED_PUBLISHERS = ["google"]
3229

3330
_SHORT_MODEL_ID_TO_TUNING_PIPELINE_MAP = {

vertexai/extensions/_extensions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ def _try_parse_execution_response(
302302
) -> Union[_utils.JsonDict, str]:
303303
content: str = response.content
304304
try:
305-
content = json.loads(response.content)
306-
except:
305+
content = json.loads(content)
306+
except json.JSONDecodeError:
307307
pass
308308
return content
309309

vertexai/language_models/_language_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4163,7 +4163,7 @@ def _uri_join(uri: str, path_fragment: str) -> str:
41634163

41644164
# Importing here to prevent issues caused by circular references
41654165
# pylint: disable=g-import-not-at-top,g-bad-import-order
4166-
from vertexai.language_models import _distillation
4166+
from vertexai.language_models import _distillation # noqa: E402
41674167

41684168

41694169
class _PreviewTextGenerationModel(

vertexai/preview/language_models.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
_PreviewTextEmbeddingModel,
2424
_PreviewTextGenerationModel,
2525
ChatMessage,
26-
ChatModel,
27-
ChatSession,
28-
CodeChatSession,
2926
CountTokensResponse,
3027
InputOutputTextPair,
3128
TextEmbedding,

vertexai/reasoning_engines/_reasoning_engines.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import typing
2323
from typing import Optional, Protocol, Sequence, Union
2424

25+
from google.api_core import exceptions
2526
from google.cloud.aiplatform import base
2627
from google.cloud.aiplatform import initializer
2728
from google.cloud.aiplatform import utils as aip_utils
@@ -378,18 +379,14 @@ def _prepare(
378379
use for staging the artifacts needed.
379380
extra_packages (Sequence[str]): The set of extra user-provided packages.
380381
"""
381-
try:
382-
from google.cloud.exceptions import NotFound
383-
except:
384-
NotFound = Exception
385382
storage = _utils._import_cloud_storage_or_raise()
386383
cloudpickle = _utils._import_cloudpickle_or_raise()
387384
storage_client = storage.Client(project=project)
388385
staging_bucket = staging_bucket.replace("gs://", "")
389386
try:
390387
gcs_bucket = storage_client.get_bucket(staging_bucket)
391388
_LOGGER.info(f"Using bucket {staging_bucket}")
392-
except NotFound:
389+
except exceptions.NotFound:
393390
new_bucket = storage_client.bucket(staging_bucket)
394391
gcs_bucket = storage_client.create_bucket(new_bucket, location=location)
395392
_LOGGER.info(f"Creating bucket {staging_bucket} in {location=}")

vertexai/tuning/_tuning.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
# pylint: disable=protected-access
1616
"""Classes to support Tuning."""
1717

18-
import typing
19-
from typing import Dict, List, Optional, Union, Sequence
18+
from typing import Dict, List, Optional, Union
2019

2120
from google.auth import credentials as auth_credentials
2221

0 commit comments

Comments
 (0)