Skip to content

Commit

Permalink
Fix Lint Issue - Final
Browse files Browse the repository at this point in the history
  • Loading branch information
RayLiu7 committed Jan 20, 2025
1 parent 231eb1d commit 7567998
Show file tree
Hide file tree
Showing 48 changed files with 131 additions and 40 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@ jobs:
- name: Install dependencies
run: python -m pip install --upgrade pip && pip install pylint

- name: Install requirements
run: |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Analyzing the code with pylint
run: pylint $(git ls-files '*.py')
3 changes: 3 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[MESSAGES CONTROL]

disable=raw-checker-failed
2 changes: 2 additions & 0 deletions PyPowerFlex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

"""This module is used for the initialization of PowerFlex Client."""

# pylint: disable=invalid-name,too-many-arguments,too-many-positional-arguments

from packaging import version

from PyPowerFlex import configuration
Expand Down
4 changes: 3 additions & 1 deletion PyPowerFlex/base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

"""This module is the base client of the PowerFlex APIs."""

# pylint: disable=no-member,import-error,broad-exception-raised

import logging

import requests
Expand Down Expand Up @@ -335,7 +337,7 @@ def _login(self):
else f'Login failed with error: {str(e)}'
)
LOG.error(error_msg)
raise Exception(error_msg)
raise Exception(error_msg) from e

def _logout(self):
"""
Expand Down
2 changes: 2 additions & 0 deletions PyPowerFlex/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

"""This module is used for the configuration of the client."""

# pylint: disable=too-many-instance-attributes,too-many-arguments,too-many-positional-arguments,too-few-public-methods

from PyPowerFlex import exceptions

class Configuration:
Expand Down
2 changes: 2 additions & 0 deletions PyPowerFlex/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

"""This module contains the definitions of constants used in the code."""

# pylint: disable=too-few-public-methods

class StoragePoolConstants:
"""
This class holds constants related to StoragePool.
Expand Down
5 changes: 2 additions & 3 deletions PyPowerFlex/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

"""This module contains the definitions of the exceptions used in the code."""

# pylint: disable=super-init-not-called

class PowerFlexClientException(Exception):
"""
Base class for all exceptions raised by the PowerFlexClient.
Expand Down Expand Up @@ -42,21 +44,18 @@ class InvalidConfiguration(PowerFlexClientException):
"""
Exception raised when the configuration is invalid.
"""
pass


class FieldsNotFound(PowerFlexClientException):
"""
Exception raised when the required fields are not found.
"""
pass


class InvalidInput(PowerFlexClientException):
"""
Exception raised when the input is invalid.
"""
pass


class PowerFlexFailCreating(PowerFlexClientException):
Expand Down
12 changes: 7 additions & 5 deletions PyPowerFlex/objects/acceleration_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

"""Module for interacting with accelaration pool APIs."""

# pylint: disable=too-few-public-methods

import logging
from PyPowerFlex import base_client
from PyPowerFlex import exceptions
Expand All @@ -40,25 +42,25 @@ def create(self,
media_type,
protection_domain_id,
name=None,
isRfcache=None):
is_rfcache=None):
"""Create PowerFlex acceleration pool.
:param media_type: one of predefined attributes of MediaType
:type media_type: str
:type protection_domain_id: str
:type name: str
:type isRfcache: bool
:type is_rfcache: bool
:rtype: dict
"""

if media_type == MediaType.ssd and not isRfcache:
msg = 'isRfcache must be set for media_type SSD.'
if media_type == MediaType.ssd and not is_rfcache:
msg = 'is_rfcache must be set for media_type SSD.'
raise exceptions.InvalidInput(msg)
params = {
'mediaType': media_type,
'protectionDomainId': protection_domain_id,
'name': name,
'isRfcache': isRfcache
'isRfcache': is_rfcache
}

return self._create_entity(params)
Expand Down
2 changes: 2 additions & 0 deletions PyPowerFlex/objects/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

"""Module for doing the deployment."""

# pylint: disable=arguments-renamed,too-many-arguments,too-many-positional-arguments,no-member

import logging
import requests
from PyPowerFlex import base_client
Expand Down
2 changes: 2 additions & 0 deletions PyPowerFlex/objects/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

"""Module for interacting with device APIs."""

# pylint: disable=too-few-public-methods,too-many-arguments,too-many-positional-arguments,no-member

import logging

import requests
Expand Down
2 changes: 2 additions & 0 deletions PyPowerFlex/objects/fault_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

"""Module for interacting with fault set APIs."""

# pylint: disable=no-member

import logging

import requests
Expand Down
2 changes: 2 additions & 0 deletions PyPowerFlex/objects/firmware_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

"""Module for interacting with firmware repository APIs."""

# pylint: disable=arguments-renamed,no-member,too-many-arguments,too-many-positional-arguments

import logging
import requests
from PyPowerFlex import base_client
Expand Down
2 changes: 2 additions & 0 deletions PyPowerFlex/objects/managed_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

"""Module for interacting with managed device APIs."""

# pylint: disable=arguments-renamed,no-member

import logging
import requests
from PyPowerFlex import base_client
Expand Down
2 changes: 2 additions & 0 deletions PyPowerFlex/objects/protection_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

"""Module for interacting with protection domain APIs."""

# pylint: disable=too-few-public-methods,no-member,too-many-arguments,too-many-positional-arguments

import logging

import requests
Expand Down
2 changes: 2 additions & 0 deletions PyPowerFlex/objects/replication_consistency_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

"""Module for interacting with replication consistency group APIs."""

# pylint: disable=too-many-public-methods,no-member,too-many-arguments,too-many-positional-arguments

import logging

import requests
Expand Down
2 changes: 2 additions & 0 deletions PyPowerFlex/objects/replication_pair.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

"""Module for interacting with replication pair APIs."""

# pylint: disable=redefined-builtin,no-member,too-many-arguments,too-many-positional-arguments,duplicate-code

import logging

import requests
Expand Down
2 changes: 0 additions & 2 deletions PyPowerFlex/objects/sdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
"""Module for interacting with SDC APIs."""

import logging
import requests
from PyPowerFlex import base_client
from PyPowerFlex import exceptions


LOG = logging.getLogger(__name__)
Expand Down
2 changes: 2 additions & 0 deletions PyPowerFlex/objects/sds.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

"""Module for interacting with SDS APIs."""

# pylint: disable=too-few-public-methods,no-member,too-many-arguments,too-many-positional-arguments,too-many-locals

import logging

import requests
Expand Down
2 changes: 2 additions & 0 deletions PyPowerFlex/objects/sdt.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

"""Module for interacting with SDT APIs."""

# pylint: disable=too-few-public-methods,no-member,too-many-arguments,too-many-positional-arguments

import logging
import requests
from PyPowerFlex import base_client
Expand Down
2 changes: 2 additions & 0 deletions PyPowerFlex/objects/service_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

"""Module for interacting with service template APIs."""

# pylint: disable=arguments-renamed,no-member,too-many-arguments,too-many-positional-arguments

import logging
import requests
from PyPowerFlex import base_client
Expand Down
10 changes: 6 additions & 4 deletions PyPowerFlex/objects/snapshot_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

"""Module for interacting with snapshot policy APIs."""

# pylint: disable=too-few-public-methods,no-member,too-many-arguments,too-many-positional-arguments

import logging

import requests
Expand Down Expand Up @@ -70,8 +72,8 @@ def create(self,
retained_snaps_per_level,
name=None,
paused=None,
snapshotAccessMode=None,
secureSnapshots=None):
snapshot_access_mode=None,
secure_snapshots=None):
"""Create PowerFlex snapshot policy.
:type auto_snap_creation_cadence_in_min: int
Expand All @@ -86,8 +88,8 @@ def create(self,
"numOfRetainedSnapshotsPerLevel": retained_snaps_per_level,
"name": name,
"paused": paused,
"snapshotAccessMode": snapshotAccessMode,
"secureSnapshots": secureSnapshots
"snapshotAccessMode": snapshot_access_mode,
"secureSnapshots": secure_snapshots
}

return self._create_entity(params)
Expand Down
11 changes: 7 additions & 4 deletions PyPowerFlex/objects/storage_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

"""Module for interacting with storage pool APIs."""

# pylint: disable=too-few-public-methods,no-member,too-many-arguments,too-many-positional-arguments,too-many-locals,cyclic-import,duplicate-code

import logging

import requests
Expand Down Expand Up @@ -359,7 +361,7 @@ def set_rebalance_enabled(self, storage_pool_id, rebalance_enabled):
"rebalanceEnabled": rebalance_enabled
}

r, response = self.send_post_request(self.base_action_url,
r, _ = self.send_post_request(self.base_action_url,
action=action,
entity=self.entity,
entity_id=storage_pool_id,
Expand Down Expand Up @@ -562,7 +564,7 @@ def set_cap_alert_thresholds(
params=params)
if r.status_code != requests.codes.ok:
msg = (
f'Failed to set the capacity alert thresholds for PowerFlex {self.entity}'
f'Failed to set the capacity alert thresholds for PowerFlex {self.entity}'
f'with id {storage_pool_id}. Error: {response}')
LOG.error(msg)
raise exceptions.PowerFlexClientException(msg)
Expand Down Expand Up @@ -595,8 +597,9 @@ def set_protected_maintenance_mode_io_priority_policy(
params=params)
if r.status_code != requests.codes.ok:
msg = (
f'Failed to set the protected maintenance mode IO priority policy for PowerFlex {self.entity} '
f'with id {storage_pool_id}. Error: {response}')
f'Failed to set the protected maintenance mode IO priority policy for '
f'PowerFlex {self.entity} with id {storage_pool_id}. Error: {response}'
)
LOG.error(msg)
raise exceptions.PowerFlexClientException(msg)

Expand Down
2 changes: 2 additions & 0 deletions PyPowerFlex/objects/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

"""Module for doing system-related operations."""

# pylint: disable=no-member,too-many-arguments,too-many-positional-arguments

import logging
import re

Expand Down
16 changes: 12 additions & 4 deletions PyPowerFlex/objects/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@

"""Utility module for PowerFlex."""

# pylint: disable=no-member,useless-parent-delegation
import logging

import requests

from PyPowerFlex import base_client
from PyPowerFlex import exceptions
from PyPowerFlex import utils
from PyPowerFlex.constants import StoragePoolConstants, VolumeConstants, SnapshotPolicyConstants


Expand Down Expand Up @@ -79,7 +79,12 @@ def get_statistics_for_all_volumes(self, ids=None, properties=None):
action = 'querySelectedStatistics'

params = {
'properties': VolumeConstants.DEFAULT_STATISTICS_PROPERTIES if properties is None else properties}
'properties': (
VolumeConstants.DEFAULT_STATISTICS_PROPERTIES
if properties is None
else properties
)
}
if ids is None:
params['allIds'] = ""
else:
Expand Down Expand Up @@ -110,8 +115,11 @@ def get_statistics_for_all_snapshot_policies(

action = 'querySelectedStatistics'

params = {
'properties': SnapshotPolicyConstants.DEFAULT_STATISTICS_PROPERTIES if properties is None else properties}
params = {}
if properties is None:
params['properties'] = SnapshotPolicyConstants.DEFAULT_STATISTICS_PROPERTIES
else:
params['properties'] = properties
if ids is None:
params['allIds'] = ""
else:
Expand Down
2 changes: 2 additions & 0 deletions PyPowerFlex/objects/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

"""Module for interacting with volume APIs."""

# pylint: disable=too-few-public-methods,no-member,too-many-arguments,too-many-positional-arguments

import logging

import requests
Expand Down
Loading

0 comments on commit 7567998

Please sign in to comment.