Skip to content

Commit

Permalink
Remove remaining pylint: disable comments (#19541)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstandish committed Nov 11, 2021
1 parent de99005 commit aa2cb55
Show file tree
Hide file tree
Showing 17 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion airflow/compat/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.

try:
from asyncio import create_task # pylint: disable=unused-import
from asyncio import create_task
except ImportError:
# create_task is not present in Python 3.6. Once Airflow is at 3.7+, we can
# remove this helper.
Expand Down
2 changes: 1 addition & 1 deletion airflow/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def _get_config_value_from_secret_backend(config_key):
if not secrets_client:
return None
return secrets_client.get_config(config_key)
except Exception as e: # pylint: disable=broad-except
except Exception as e:
raise AirflowConfigException(
'Cannot retrieve config from alternative secrets backend. '
'Make sure it is configured properly and that the Backend '
Expand Down
9 changes: 4 additions & 5 deletions airflow/jobs/triggerer_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def on_kill(self):
"""
self.runner.stop = True

def _exit_gracefully(self, signum, frame) -> None: # pylint: disable=unused-argument
def _exit_gracefully(self, signum, frame) -> None:
"""Helper method to clean up processor_agent to avoid leaving orphan processes."""
# The first time, try to exit nicely
if not self.runner.stop:
Expand All @@ -104,7 +104,7 @@ def _execute(self) -> None:
self.runner.start()
# Start our own DB loop in the main thread
self._run_trigger_loop()
except Exception: # pylint: disable=broad-except
except Exception:
self.log.exception("Exception when executing TriggererJob._run_trigger_loop")
raise
finally:
Expand Down Expand Up @@ -227,8 +227,7 @@ def __init__(self):

def run(self):
"""Sync entrypoint - just runs arun in an async loop."""
# Pylint complains about this with a 3.6 base, can remove with 3.7+
asyncio.run(self.arun()) # pylint: disable=no-member
asyncio.run(self.arun())

async def arun(self):
"""
Expand Down Expand Up @@ -288,7 +287,7 @@ async def cleanup_finished_triggers(self):
ones that have exited, optionally warning users if the exit was
not normal.
"""
for trigger_id, details in list(self.triggers.items()): # pylint: disable=too-many-nested-blocks
for trigger_id, details in list(self.triggers.items()):
if details["task"].done():
# Check to see if it exited for good reasons
try:
Expand Down
2 changes: 1 addition & 1 deletion airflow/models/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def get_connection_from_secrets(cls, conn_id: str) -> 'Connection':
conn = secrets_backend.get_connection(conn_id=conn_id)
if conn:
return conn
except Exception: # pylint: disable=broad-except
except Exception:
log.exception(
'Unable to retrieve connection from secrets backend (%s). '
'Checking subsequent secrets backend.',
Expand Down
4 changes: 2 additions & 2 deletions airflow/models/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def check_for_write_conflict(key: str) -> None:
"from {cls}".format(key=key, cls=secrets_backend.__class__.__name__)
)
return
except Exception: # pylint: disable=broad-except
except Exception:
log.exception(
'Unable to retrieve variable from secrets backend (%s). '
'Checking subsequent secrets backend.',
Expand All @@ -267,7 +267,7 @@ def get_variable_from_secrets(key: str) -> Optional[str]:
var_val = secrets_backend.get_variable(key=key)
if var_val is not None:
return var_val
except Exception: # pylint: disable=broad-except
except Exception:
log.exception(
'Unable to retrieve variable from secrets backend (%s). '
'Checking subsequent secrets backend.',
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/amazon/aws/hooks/base_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def _create_session_with_assume_role(self, session_kwargs: Dict[str, Any]) -> bo
method="sts-assume-role",
)
session = botocore.session.get_session()
session._credentials = credentials # pylint: disable=protected-access
session._credentials = credentials
region_name = self.basic_session.region_name
session.set_config_variable("region", region_name)
return boto3.session.Session(botocore_session=session, **session_kwargs)
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/amazon/aws/operators/emr_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class EMRContainerOperator(BaseOperator):
template_fields = ["name", "virtual_cluster_id", "execution_role_arn", "release_label", "job_driver"]
ui_color = "#f9c915"

def __init__( # pylint: disable=too-many-arguments
def __init__(
self,
*,
name: str,
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/docker/decorators/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def _get_python_source(self):
return res


T = TypeVar("T", bound=Callable) # pylint: disable=invalid-name
T = TypeVar("T", bound=Callable)


def docker_task(
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/google/cloud/hooks/dataproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ def instantiate_workflow_template(
retry: Optional[Retry] = None,
timeout: Optional[float] = None,
metadata: Optional[Sequence[Tuple[str, str]]] = None,
): # pylint: disable=too-many-arguments
):
"""
Instantiates a template and begins execution.
Expand Down
2 changes: 1 addition & 1 deletion airflow/sensors/date_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ def execute(self, context):
method_name="execute_complete",
)

def execute_complete(self, context, event=None): # pylint: disable=unused-argument
def execute_complete(self, context, event=None):
"""Callback for when the trigger fires - returns immediately."""
return None
2 changes: 1 addition & 1 deletion airflow/sensors/time_delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ def execute(self, context):
target_dttm += self.delta
self.defer(trigger=DateTimeTrigger(moment=target_dttm), method_name="execute_complete")

def execute_complete(self, context, event=None): # pylint: disable=unused-argument
def execute_complete(self, context, event=None):
"""Callback for when the trigger fires - returns immediately."""
return None
2 changes: 1 addition & 1 deletion airflow/sensors/time_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ def execute(self, context):
method_name="execute_complete",
)

def execute_complete(self, context, event=None): # pylint: disable=unused-argument
def execute_complete(self, context, event=None):
"""Callback for when the trigger fires - returns immediately."""
return None
2 changes: 1 addition & 1 deletion airflow/triggers/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ def serialize(self) -> Tuple[str, Dict[str, Any]]:
async def run(self):
# Python needs at least one "yield" keyword in the body to make
# this an async generator.
if False: # pylint: disable=using-constant-test
if False:
yield None
raise ValueError("Deliberate trigger failure")
4 changes: 2 additions & 2 deletions airflow/utils/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def process_bind_param(self, value, dialect):
return None

# First, encode it into our custom JSON-targeted dict format
value = BaseSerialization._serialize(value) # pylint: disable=protected-access
value = BaseSerialization._serialize(value)

# Then, if the database does not have native JSON support, encode it again as a string
if not self.db_supports_json():
Expand All @@ -132,7 +132,7 @@ def process_result_value(self, value, dialect):
if not self.db_supports_json():
value = json.loads(value)

return BaseSerialization._deserialize(value) # pylint: disable=protected-access
return BaseSerialization._deserialize(value)


class Interval(TypeDecorator):
Expand Down
2 changes: 1 addition & 1 deletion airflow/utils/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class TaskInstanceState(str, Enum):
SENSING = "sensing" # Smart sensor offloaded to the sensor DAG
DEFERRED = "deferred" # Deferrable operator waiting on a trigger

def __str__(self) -> str: # pylint: disable=invalid-str-returned
def __str__(self) -> str:
return self.value


Expand Down
2 changes: 1 addition & 1 deletion airflow/www/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3142,7 +3142,7 @@ def apply(self, query, func):
class DagEditFilter(BaseFilter):
"""Filter using DagIDs"""

def apply(self, query, func): # pylint: disable=redefined-outer-name,unused-argument
def apply(self, query, func):
filter_dag_ids = current_app.appbuilder.sm.get_editable_dag_ids(g.user)
return query.filter(self.model.dag_id.in_(filter_dag_ids))

Expand Down
4 changes: 2 additions & 2 deletions tests/providers/amazon/aws/operators/test_ecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def test_reattach_successful(
self, launch_type, tags, start_mock, check_mock, wait_mock, xcom_pull_mock, xcom_del_mock
):

self.set_up_operator(launch_type=launch_type, tags=tags) # pylint: disable=no-value-for-parameter
self.set_up_operator(launch_type=launch_type, tags=tags)
client_mock = self.aws_hook_mock.return_value.get_conn.return_value
client_mock.describe_task_definition.return_value = {'taskDefinition': {'family': 'f'}}
client_mock.list_tasks.return_value = {
Expand Down Expand Up @@ -476,7 +476,7 @@ def test_reattach_save_task_arn_xcom(
self, launch_type, tags, check_mock, wait_mock, reattach_mock, xcom_set_mock, xcom_del_mock
):

self.set_up_operator(launch_type=launch_type, tags=tags) # pylint: disable=no-value-for-parameter
self.set_up_operator(launch_type=launch_type, tags=tags)
client_mock = self.aws_hook_mock.return_value.get_conn.return_value
client_mock.describe_task_definition.return_value = {'taskDefinition': {'family': 'f'}}
client_mock.list_tasks.return_value = {'taskArns': []}
Expand Down

0 comments on commit aa2cb55

Please sign in to comment.