Skip to content

Commit

Permalink
remove pylint disable (Azure#38979)
Browse files Browse the repository at this point in the history
  • Loading branch information
PratibhaShrivastav18 authored Dec 24, 2024
1 parent 693084d commit b52b61c
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def _try_build_local_code(self) -> Iterable[Code]:

tmp_code_dir: Path
# origin code value of internal component will never be None. check _get_origin_code_value for details
with self._generate_additional_includes_obj().merge_local_code_and_additional_includes() as tmp_code_dir: # pylint:disable=contextmanager-generator-missing-cleanup
with self._generate_additional_includes_obj().merge_local_code_and_additional_includes() as tmp_code_dir:
# use absolute path in case temp folder & work dir are in different drive
tmp_code_dir = tmp_code_dir.absolute()

Expand Down
8 changes: 4 additions & 4 deletions sdk/ml/azure-ai-ml/azure/ai/ml/_telemetry/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import os
import uuid
from datetime import datetime
from typing import Any, Dict, Tuple
from typing import Dict, Tuple
from uuid import uuid4

from marshmallow import ValidationError
Expand Down Expand Up @@ -153,12 +153,12 @@ def error_preprocess(activityLogger, exception):


@contextlib.contextmanager
def log_activity( # pylint:disable=useless-return
def log_activity(
logger,
activity_name,
activity_type=ActivityType.INTERNALCALL,
custom_dimensions=None,
) -> Any:
):
"""Log an activity.
An activity is a logical block of code that consumers want to monitor.
Expand Down Expand Up @@ -248,7 +248,7 @@ def log_activity( # pylint:disable=useless-return
else:
activityLogger.info(message)
except Exception: # pylint: disable=W0718
return # pylint: disable=lost-exception,return-in-finally
pass


# pylint: disable-next=docstring-missing-rtype
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,12 +473,12 @@ def merge_local_code_and_additional_includes(self) -> Generator:
)
else:
raise ValueError(f"Unable to find additional include {additional_include_local_path}.")
try:
yield tmp_folder_path.absolute()

yield tmp_folder_path.absolute()

# clean up tmp folder as it can be very disk space consuming
shutil.rmtree(tmp_folder_path, ignore_errors=True)
return
finally:
# clean up tmp folder as it can be very disk space consuming
shutil.rmtree(tmp_folder_path, ignore_errors=True)


class AdditionalIncludesMixin(ComponentCodeMixin):
Expand Down
3 changes: 3 additions & 0 deletions sdk/ml/azure-ai-ml/azure/ai/ml/entities/_component/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ def _build_code(self) -> Generator:
yield Code(path=origin_code_value)
elif code_type in [CodeType.LOCAL, CodeType.NONE]:
code: Any
# false-positive by pylint, hence disable it
# (https://github.com/pylint-dev/pylint/blob/main/doc/data/messages
# /c/contextmanager-generator-missing-cleanup/details.rst)
with self._try_build_local_code() as code: # pylint:disable=contextmanager-generator-missing-cleanup
yield code
else:
Expand Down
3 changes: 3 additions & 0 deletions sdk/ml/azure-ai-ml/azure/ai/ml/entities/_component/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,9 @@ def _fill_back_code_value(self, value: str) -> None:

@contextlib.contextmanager
def _try_build_local_code(self) -> Generator:
# false-positive by pylint, hence disable it
# (https://github.com/pylint-dev/pylint/blob/main/doc/data/messages
# /c/contextmanager-generator-missing-cleanup/details.rst)
with super()._try_build_local_code() as code: # pylint:disable=contextmanager-generator-missing-cleanup
if not code or not code.path:
yield code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ def set_limits(
:keyword trial_timeout: timeout in seconds for each trial
:paramtype trial_timeout: int
"""
# Looks related to https://github.com/pylint-dev/pylint/issues/3502, still an open issue
# pylint:disable=attribute-defined-outside-init
if self._limits is None:
self._limits = SweepJobLimits(
Expand Down

0 comments on commit b52b61c

Please sign in to comment.