Skip to content

Commit 96389f1

Browse files
author
Mark Beacom
authored
Adjust linting (#110)
* Adjust linting and black config * Adjust GH action for linting
1 parent 480c4dd commit 96389f1

21 files changed

+156
-405
lines changed

.github/workflows/lint-python.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
max-parallel: 4
1313
matrix:
14-
python-version: ['3.7']
14+
python-version: ['3.8']
1515
steps:
1616
- uses: actions/checkout@v1
1717
- name: Set up Python ${{ matrix.python-version }}
@@ -34,4 +34,4 @@ jobs:
3434
- name: Lint with Black
3535
run: |
3636
black --version
37-
black --target-version py37 --check .
37+
black --check .

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ push: ## Push the Docker image to the Docker Hub repository.
5555
docker: build build_py38 ## Build and publish Docker images.
5656

5757
lint: isort ## Lint the CloudEndure project with Black.
58-
@poetry run black --target-version py37 .
58+
@poetry run black .
5959

6060
update_prereqs: ## Update the local development pre-requisite packages.
6161
@pip install --upgrade wheel setuptools pip

cloudendure/api.py

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -117,24 +117,16 @@ def login(self, username: str = "", password: str = "", token: str = "") -> bool
117117
return False
118118

119119
# Attempt to login to the CloudEndure API via a POST request.
120-
response: requests.Response = self.api_call(
121-
"login", "post", data=json.dumps(_auth)
122-
)
120+
response: requests.Response = self.api_call("login", "post", data=json.dumps(_auth))
123121

124122
# Check whether or not the request was successful.
125123
if response.status_code not in [200, 307]:
126124
if response.status_code == 401:
127-
print(
128-
"\nBad CloudEndure Credentials! Check your username/password and try again!\n"
129-
)
125+
print("\nBad CloudEndure Credentials! Check your username/password and try again!\n")
130126
elif response.status_code == 402:
131-
print(
132-
"\nNo CloudEndure License! Please configure your account and try again!\n"
133-
)
127+
print("\nNo CloudEndure License! Please configure your account and try again!\n")
134128
elif response.status_code == 429:
135-
print(
136-
"\nCloudEndure authentication failure limit reached! Please try again later!\n"
137-
)
129+
print("\nCloudEndure authentication failure limit reached! Please try again later!\n")
138130
return False
139131

140132
# Grab the XSRF token received from the response, as stored in cookies.
@@ -155,11 +147,7 @@ def login(self, username: str = "", password: str = "", token: str = "") -> bool
155147
return True
156148

157149
@staticmethod
158-
def get_endpoint(
159-
path: str,
160-
api_version: str = "latest",
161-
host: str = "https://console.cloudendure.com",
162-
) -> str:
150+
def get_endpoint(path: str, api_version: str = "latest", host: str = "https://console.cloudendure.com",) -> str:
163151
"""Build the endpoint path.
164152
165153
Returns:
@@ -168,9 +156,7 @@ def get_endpoint(
168156
"""
169157
return f"{host}/api/{api_version}/{path}"
170158

171-
def api_call(
172-
self, path: str, method: str = "get", data: Dict[str, Any] = None
173-
) -> Response:
159+
def api_call(self, path: str, method: str = "get", data: Dict[str, Any] = None) -> Response:
174160
"""Handle CloudEndure API calls based on the defined parameters.
175161
176162
Args:
@@ -194,9 +180,7 @@ def api_call(
194180
return Response()
195181

196182
if method not in ["get", "delete"] and not data:
197-
print(
198-
"Paramater mismatch! If calling anything other than get or delete provide data!"
199-
)
183+
print("Paramater mismatch! If calling anything other than get or delete provide data!")
200184
return Response()
201185

202186
# Attempt to call the CloudEndure API.
@@ -238,17 +222,13 @@ def get_projects(self, current_project: str = "") -> List[Any]:
238222
self.projects: List[Any] = projects
239223

240224
if current_project:
241-
return list(
242-
filter(lambda project: project["name"] == current_project, projects)
243-
)
225+
return list(filter(lambda project: project["name"] == current_project, projects))
244226

245227
return projects
246228

247229
@classmethod
248230
def docs(self) -> str:
249231
"""Open the CloudEndure API documentation page."""
250-
docs_url: str = os.environ.get(
251-
"CLOUDENDURE_API_DOCS", "https://console.cloudendure.com/api_doc/apis.html"
252-
)
232+
docs_url: str = os.environ.get("CLOUDENDURE_API_DOCS", "https://console.cloudendure.com/api_doc/apis.html")
253233
open_new_tab(docs_url)
254234
return docs_url

0 commit comments

Comments
 (0)