Skip to content

Commit

Permalink
Enable Lint and Fix Issues
Browse files Browse the repository at this point in the history
  • Loading branch information
RayLiu7 committed Jan 20, 2025
1 parent d590af9 commit 77706cf
Show file tree
Hide file tree
Showing 51 changed files with 3,221 additions and 1,248 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Run Lint Check via Pylint

on: [push]

jobs:
lint:
name: lint
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']

steps:
- name: Checkout the source code
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- 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')
26 changes: 23 additions & 3 deletions PyPowerFlex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.

"""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 All @@ -28,6 +32,12 @@


class PowerFlexClient:
"""
Client class for interacting with PowerFlex API.
This class initializes the client with the provided configuration and provides
access to the various storage entities available in the PowerFlex system.
"""
__slots__ = (
'__is_initialized',
'configuration',
Expand Down Expand Up @@ -76,12 +86,18 @@ def __init__(self,
def __getattr__(self, item):
if not self.__is_initialized and item in self.__slots__:
raise exceptions.ClientNotInitialized
return super(PowerFlexClient, self).__getattribute__(item)
return super().__getattribute__(item)

def __add_storage_entity(self, attr_name, entity_class):
setattr(self, attr_name, entity_class(self.token, self.configuration))

def initialize(self):
"""
Initializes the client.
Raises:
PowerFlexClientException: If the PowerFlex API version is lower than 3.0.
"""
self.configuration.validate()
self.__add_storage_entity('device', objects.Device)
self.__add_storage_entity('fault_set', objects.FaultSet)
Expand All @@ -97,12 +113,16 @@ def initialize(self):
self.__add_storage_entity('system', objects.System)
self.__add_storage_entity('volume', objects.Volume)
self.__add_storage_entity('utility', objects.PowerFlexUtility)
self.__add_storage_entity('replication_consistency_group', objects.ReplicationConsistencyGroup)
self.__add_storage_entity(
'replication_consistency_group',
objects.ReplicationConsistencyGroup)
self.__add_storage_entity('replication_pair', objects.ReplicationPair)
self.__add_storage_entity('service_template', objects.ServiceTemplate)
self.__add_storage_entity('managed_device', objects.ManagedDevice)
self.__add_storage_entity('deployment', objects.Deployment)
self.__add_storage_entity('firmware_repository', objects.FirmwareRepository)
self.__add_storage_entity(
'firmware_repository',
objects.FirmwareRepository)
self.__add_storage_entity('host', objects.Host)
utils.init_logger(self.configuration.log_level)
if version.parse(self.system.api_version()) < version.Version('3.0'):
Expand Down
Loading

0 comments on commit 77706cf

Please sign in to comment.