Skip to content

Commit

Permalink
feat(Quality): Add Quality Tools: iSort (#4)
Browse files Browse the repository at this point in the history
Automatic import ordering.

PR: #4
  • Loading branch information
mohnoor94 authored Jan 15, 2023
1 parent e2d5740 commit a48a6d1
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 30 deletions.
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ ignore =

require-plugins =
flake8-bugbear
flake8-isort
13 changes: 11 additions & 2 deletions QUALITY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# Run Quality Checks
# Quality Checks

### Running the Checks

To run the code quality checks, run the following command:

```bash
flake8
```
```

### Fixing Code Quality Issues

- If you have `isort` installed, you can run `isort .` to automatically fix import order issues.
- `flake8` will report `isort` related issues as `I` errors.
- You may fix other issues manually.
2 changes: 1 addition & 1 deletion generator/scripts/add-imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

"""Add imports to all generated models."""

import pathlib
import ast
import pathlib
import sys


Expand Down
15 changes: 8 additions & 7 deletions openworld/sdk/core/client/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,22 @@
# limitations under the License.

import logging
from datetime import datetime
from enum import Enum
import requests
from http import HTTPStatus
from typing import Any, Dict, Optional
from datetime import datetime

import requests

from openworld.sdk.core.client.auth_client import _AuthClient
from openworld.sdk.core.configuration.client_config import ClientConfig
from openworld.sdk.core.constant import header as header_constant
from openworld.sdk.core.util import log as log_util
from openworld.sdk.core.constant import log as log_constant
from http import HTTPStatus
from openworld.sdk.core.constant.constant import OK_STATUS_CODES_RANGE
from openworld.sdk.core.client.auth_client import _AuthClient
from openworld.sdk.core.model.authentication import HttpBearerAuth
from openworld.sdk.core.configuration.client_config import ClientConfig
from openworld.sdk.core.model.exception import service as service_exception
from openworld.sdk.core.model.error import Error
from openworld.sdk.core.model.exception import service as service_exception
from openworld.sdk.core.util import log as log_util

LOG = logging.getLogger(__name__)

Expand Down
12 changes: 5 additions & 7 deletions openworld/sdk/core/client/auth_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,19 @@
# limitations under the License.

import logging

from http import HTTPStatus

from requests import Response, post
from requests.auth import HTTPBasicAuth

from openworld.sdk.core.constant import (body as body_constant,
url as url_constant,
log as log_constant)
from openworld.sdk.core.util import log as log_util
from openworld.sdk.core.constant import body as body_constant
from openworld.sdk.core.constant import log as log_constant
from openworld.sdk.core.constant import url as url_constant
from openworld.sdk.core.constant.constant import OK_STATUS_CODES_RANGE
from openworld.sdk.core.constant.message import UNABLE_TO_AUTHENTICATE
from openworld.sdk.core.model.authentication import Credentials
from openworld.sdk.core.model.authentication import Token
from openworld.sdk.core.model.authentication import Credentials, Token
from openworld.sdk.core.model.exception import service as service_exception
from openworld.sdk.core.util import log as log_util

LOG = logging.getLogger(__name__)

Expand Down
6 changes: 3 additions & 3 deletions openworld/sdk/core/configuration/auth_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from dataclasses import dataclass

from openworld.sdk.core.constant import message
from openworld.sdk.core.model.authentication import Credentials
from openworld.sdk.core.constant.constant import EMPTY_STRING
from openworld.sdk.core.constant.url import AUTH_ENDPOINT
from dataclasses import dataclass

from openworld.sdk.core.model.authentication import Credentials
from openworld.sdk.core.model.exception import client as client_exception

DEFAULT_CREDENTIALS = Credentials(key=EMPTY_STRING, secret=EMPTY_STRING)
Expand Down
5 changes: 3 additions & 2 deletions openworld/sdk/core/configuration/client_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Optional
from dataclasses import dataclass
from typing import Optional

from openworld.sdk.core.configuration.auth_config import AuthConfig
from openworld.sdk.core.constant import url, message
from openworld.sdk.core.constant import message, url
from openworld.sdk.core.model.authentication import Credentials
from openworld.sdk.core.model.exception import client as client_exception

Expand Down
1 change: 1 addition & 0 deletions openworld/sdk/core/constant/body.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

from typing import Dict

from openworld.sdk.core.constant import header

TOKEN_REQUEST: Dict = {header.GRANT_TYPE: header.CLIENT_CREDENTIALS}
9 changes: 4 additions & 5 deletions openworld/sdk/core/model/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import requests
import datetime
import logging
from openworld.sdk.core.constant import log
from dataclasses import dataclass
from dataclasses_json import dataclass_json
from typing import Dict, Optional
from multiprocessing import Lock
from typing import Dict, Optional

import requests
from dataclasses_json import dataclass_json
from requests.auth import AuthBase

from openworld.sdk.core.constant import header
from openworld.sdk.core.constant import header, log
from openworld.sdk.core.constant.constant import REFRESH_TOKEN_TIME_GAP_IN_SECONDS

LOG = logging.getLogger(__name__)
Expand Down
5 changes: 3 additions & 2 deletions openworld/sdk/core/model/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Optional
from enum import Enum
from dataclasses import dataclass
from enum import Enum
from typing import Optional

from dataclasses_json import dataclass_json


Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[tool.isort]
profile = "black"
multi_line_output = 1
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ setuptools
virtualenv
coverage
flake8~=6.0.0
flake8-bugbear~=22.12.6
flake8-bugbear~=22.12.6
flake8-isort~=6.0.0

0 comments on commit a48a6d1

Please sign in to comment.