Skip to content

Commit

Permalink
Merge pull request #478 from ogajduse/fix/black-formatting-202404
Browse files Browse the repository at this point in the history
  • Loading branch information
ogajduse authored Apr 17, 2024
2 parents 4e0778b + 73a1350 commit 86cf82d
Show file tree
Hide file tree
Showing 33 changed files with 172 additions and 234 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ dist/
.tox/
AUTHORS
ChangeLog
vcd_sdk.log
19 changes: 8 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
ci:
autofix_prs: false
repos:
- repo: https://github.com/asottile/reorder-python-imports
rev: v3.12.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.3.7
hooks:
- id: reorder-python-imports
args:
- --application-directories=.:wrapanapi
- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black
args: [--safe, --quiet, --line-length, "100"]
require_serial: true
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
Expand Down
22 changes: 22 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,25 @@ test = [
"pytest-variables",
"coveralls",
]

[tool.ruff]
line-length = 100
indent-width = 4

[tool.ruff.format]
# Like Black, use double quotes for strings.
quote-style = "double"

# Like Black, indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"

[tool.ruff.lint]
select = ["I"]

ignore = []
6 changes: 2 additions & 4 deletions tests/test_hawkular.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Unit tests for Hawkular client."""

import json
import os
from random import sample
Expand All @@ -8,10 +9,7 @@
import pytest

from wrapanapi.systems import HawkularSystem
from wrapanapi.systems.hawkular import CanonicalPath
from wrapanapi.systems.hawkular import Resource
from wrapanapi.systems.hawkular import ResourceData
from wrapanapi.systems.hawkular import ResourceType
from wrapanapi.systems.hawkular import CanonicalPath, Resource, ResourceData, ResourceType


def fake_urlopen(c_client, url, headers, params):
Expand Down
6 changes: 2 additions & 4 deletions tests/test_vm_and_template_systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
If running within a cfme venv, disable the cfme plugins like so:
$ pytest test_vm_and_template_systems.py -p no:cfme -s
"""

import datetime
import logging

Expand All @@ -17,10 +18,7 @@
from wrapanapi import VmState
from wrapanapi.entities import StackMixin
from wrapanapi.exceptions import MultipleItemsError
from wrapanapi.systems.ec2 import EC2Image
from wrapanapi.systems.ec2 import EC2Instance
from wrapanapi.systems.ec2 import StackStates

from wrapanapi.systems.ec2 import EC2Image, EC2Instance, StackStates

log = logging.getLogger("wrapanapi.tests.test_vm_and_template_systems")

Expand Down
3 changes: 1 addition & 2 deletions wrapanapi/clients/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from .rest_client import ContainerClient
from .websocket_client import HawkularWebsocketClient
from .websocket_client import WebsocketClient
from .websocket_client import HawkularWebsocketClient, WebsocketClient

__all__ = ["ContainerClient", "WebsocketClient", "HawkularWebsocketClient"]
20 changes: 7 additions & 13 deletions wrapanapi/entities/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
"""
wrapanapi.entities
"""

from .instance import Instance
from .network import Network
from .network import NetworkMixin
from .network import Network, NetworkMixin
from .physical_container import PhysicalContainer
from .server import Server
from .server import ServerState
from .stack import Stack
from .stack import StackMixin
from .template import Template
from .template import TemplateMixin
from .vm import Vm
from .vm import VmMixin
from .vm import VmState
from .volume import Volume
from .volume import VolumeMixin
from .server import Server, ServerState
from .stack import Stack, StackMixin
from .template import Template, TemplateMixin
from .vm import Vm, VmMixin, VmState
from .volume import Volume, VolumeMixin

__all__ = [
"Template",
Expand Down
5 changes: 2 additions & 3 deletions wrapanapi/entities/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
Provides method/class definitions for handling any entity on a provider
"""
from abc import ABCMeta
from abc import abstractmethod
from abc import abstractproperty

from abc import ABCMeta, abstractmethod, abstractproperty
from reprlib import aRepr

from wrapanapi.exceptions import NotFoundError
Expand Down
4 changes: 2 additions & 2 deletions wrapanapi/entities/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Instances which run on cloud providers
"""
from abc import ABCMeta
from abc import abstractproperty

from abc import ABCMeta, abstractproperty

from .vm import Vm

Expand Down
10 changes: 4 additions & 6 deletions wrapanapi/entities/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
Networks
"""
from abc import ABCMeta
from abc import abstractmethod

from wrapanapi.entities.base import Entity
from wrapanapi.entities.base import EntityMixin
from wrapanapi.exceptions import MultipleItemsError
from wrapanapi.exceptions import NotFoundError
from abc import ABCMeta, abstractmethod

from wrapanapi.entities.base import Entity, EntityMixin
from wrapanapi.exceptions import MultipleItemsError, NotFoundError


class Network(Entity, metaclass=ABCMeta):
Expand Down
1 change: 1 addition & 0 deletions wrapanapi/entities/physical_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
blocks, sleds, chassis or enclosures that contain other physical entities such
as physical servers.
"""

from abc import ABCMeta

from wrapanapi.entities.base import Entity
Expand Down
4 changes: 2 additions & 2 deletions wrapanapi/entities/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Implements classes and methods related to actions performed on (physical) servers
"""
from abc import ABCMeta
from abc import abstractmethod

from abc import ABCMeta, abstractmethod

from wrapanapi.entities.base import Entity

Expand Down
10 changes: 4 additions & 6 deletions wrapanapi/entities/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
Orchestration stacks
"""
from abc import ABCMeta
from abc import abstractmethod

from wrapanapi.entities.base import Entity
from wrapanapi.entities.base import EntityMixin
from wrapanapi.exceptions import MultipleItemsError
from wrapanapi.exceptions import NotFoundError
from abc import ABCMeta, abstractmethod

from wrapanapi.entities.base import Entity, EntityMixin
from wrapanapi.exceptions import MultipleItemsError, NotFoundError


class Stack(Entity, metaclass=ABCMeta):
Expand Down
10 changes: 4 additions & 6 deletions wrapanapi/entities/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
Methods/classes pertaining to performing actions on a template
"""
from abc import ABCMeta
from abc import abstractmethod

from wrapanapi.entities.base import Entity
from wrapanapi.entities.base import EntityMixin
from wrapanapi.exceptions import MultipleItemsError
from wrapanapi.exceptions import NotFoundError
from abc import ABCMeta, abstractmethod

from wrapanapi.entities.base import Entity, EntityMixin
from wrapanapi.exceptions import MultipleItemsError, NotFoundError


class Template(Entity, metaclass=ABCMeta):
Expand Down
14 changes: 5 additions & 9 deletions wrapanapi/entities/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@
Methods/classes pertaining to performing actions on a VM/instance
"""

import time
from abc import ABCMeta
from abc import abstractmethod
from abc import abstractproperty
from abc import ABCMeta, abstractmethod, abstractproperty

from cached_property import cached_property_with_ttl
from wait_for import TimedOutError
from wait_for import wait_for
from wait_for import TimedOutError, wait_for

from wrapanapi.const import CACHED_PROPERTY_TTL
from wrapanapi.entities.base import Entity
from wrapanapi.entities.base import EntityMixin
from wrapanapi.exceptions import MultipleItemsError
from wrapanapi.exceptions import NotFoundError
from wrapanapi.entities.base import Entity, EntityMixin
from wrapanapi.exceptions import MultipleItemsError, NotFoundError


class VmState:
Expand Down
10 changes: 4 additions & 6 deletions wrapanapi/entities/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
Volumes
"""
from abc import ABCMeta
from abc import abstractmethod

from wrapanapi.entities.base import Entity
from wrapanapi.entities.base import EntityMixin
from wrapanapi.exceptions import MultipleItemsError
from wrapanapi.exceptions import NotFoundError
from abc import ABCMeta, abstractmethod

from wrapanapi.entities.base import Entity, EntityMixin
from wrapanapi.exceptions import MultipleItemsError, NotFoundError


class Volume(Entity, metaclass=ABCMeta):
Expand Down
5 changes: 2 additions & 3 deletions wrapanapi/systems/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
Used to communicate with providers without using CFME facilities
"""
from abc import ABCMeta
from abc import abstractmethod
from abc import abstractproperty

from abc import ABCMeta, abstractmethod, abstractproperty

from wrapanapi.utils import LoggerMixin

Expand Down
10 changes: 3 additions & 7 deletions wrapanapi/systems/container/rhopenshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,19 @@
import json
import string
from collections.abc import Iterable
from functools import partial
from functools import wraps
from functools import partial, wraps
from random import choice

import inflection
import yaml
from kubernetes import client as kubeclient
from kubernetes.client.rest import ApiException
from miq_version import TemplateName
from miq_version import Version
from miq_version import TemplateName, Version
from openshift import client as ociclient
from wait_for import TimedOutError
from wait_for import wait_for
from wait_for import TimedOutError, wait_for

from wrapanapi.systems.base import System


# this service allows to access db outside of openshift
common_service = """
{
Expand Down
26 changes: 13 additions & 13 deletions wrapanapi/systems/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
from botocore.config import Config
from botocore.exceptions import ClientError

from wrapanapi.entities import Instance
from wrapanapi.entities import Network
from wrapanapi.entities import NetworkMixin
from wrapanapi.entities import Stack
from wrapanapi.entities import StackMixin
from wrapanapi.entities import Template
from wrapanapi.entities import TemplateMixin
from wrapanapi.entities import VmMixin
from wrapanapi.entities import VmState
from wrapanapi.entities import Volume
from wrapanapi.exceptions import ActionTimedOutError
from wrapanapi.exceptions import MultipleItemsError
from wrapanapi.exceptions import NotFoundError
from wrapanapi.entities import (
Instance,
Network,
NetworkMixin,
Stack,
StackMixin,
Template,
TemplateMixin,
VmMixin,
VmState,
Volume,
)
from wrapanapi.exceptions import ActionTimedOutError, MultipleItemsError, NotFoundError
from wrapanapi.systems.base import System


Expand Down
17 changes: 8 additions & 9 deletions wrapanapi/systems/google.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Defines System and Entity classes related to the Google Cloud platform
"""

import os
import random
import time
Expand All @@ -15,15 +16,13 @@
from oauth2client.service_account import ServiceAccountCredentials
from wait_for import wait_for

from wrapanapi.entities import Instance
from wrapanapi.entities import Template
from wrapanapi.entities import TemplateMixin
from wrapanapi.entities import VmMixin
from wrapanapi.entities import VmState
from wrapanapi.exceptions import ImageNotFoundError
from wrapanapi.exceptions import MultipleInstancesError
from wrapanapi.exceptions import NotFoundError
from wrapanapi.exceptions import VMInstanceNotFound
from wrapanapi.entities import Instance, Template, TemplateMixin, VmMixin, VmState
from wrapanapi.exceptions import (
ImageNotFoundError,
MultipleInstancesError,
NotFoundError,
VMInstanceNotFound,
)
from wrapanapi.systems.base import System

# Retry transport and file IO errors.
Expand Down
3 changes: 1 addition & 2 deletions wrapanapi/systems/hawkular.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

from packaging import version

from wrapanapi.clients import ContainerClient
from wrapanapi.clients import HawkularWebsocketClient
from wrapanapi.clients import ContainerClient, HawkularWebsocketClient
from wrapanapi.systems.base import System

"""
Expand Down
1 change: 1 addition & 0 deletions wrapanapi/systems/lenovo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Backend management system classes
Used to communicate with providers without using CFME facilities
"""

import json

import requests
Expand Down
Loading

0 comments on commit 86cf82d

Please sign in to comment.