Skip to content

Commit ea79872

Browse files
authored
CM-24996 - Integrate Black code formatter (#133)
1 parent 657c7fc commit ea79872

49 files changed

Lines changed: 1001 additions & 624 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/black.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Black (code formatter)
2+
3+
on: [ pull_request, push ]
4+
5+
jobs:
6+
black:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Run Cimon
11+
uses: cycodelabs/cimon-action@v0
12+
with:
13+
client-id: ${{ secrets.CIMON_CLIENT_ID }}
14+
secret: ${{ secrets.CIMON_SECRET }}
15+
prevent: true
16+
allowed-hosts: >
17+
files.pythonhosted.org
18+
install.python-poetry.org
19+
pypi.org
20+
21+
- name: Checkout repository
22+
uses: actions/checkout@v3
23+
24+
- name: Setup Python
25+
uses: actions/setup-python@v4
26+
with:
27+
python-version: 3.7
28+
29+
- name: Setup Poetry
30+
uses: snok/install-poetry@v1
31+
32+
- name: Install dependencies
33+
run: poetry install
34+
35+
- name: Check code style of package
36+
run: poetry run black --check cycode
37+
38+
- name: Check code style of tests
39+
run: poetry run black --check tests

cycode/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.0.0' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
1+
__version__ = '0.0.0' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag

cycode/cli/auth/auth_command.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
@click.group(invoke_without_command=True)
1414
@click.pass_context
1515
def authenticate(context: click.Context):
16-
""" Authenticates your machine to associate CLI with your cycode account """
16+
"""Authenticates your machine to associate CLI with your cycode account"""
1717
if context.invoked_subcommand is not None:
1818
# if it is a subcommand do nothing
1919
return
@@ -33,7 +33,7 @@ def authenticate(context: click.Context):
3333
@authenticate.command(name='check')
3434
@click.pass_context
3535
def authorization_check(context: click.Context):
36-
""" Check your machine associating CLI with your cycode account """
36+
"""Check your machine associating CLI with your cycode account"""
3737
printer = ConsolePrinter(context)
3838

3939
passed_auth_check_res = CliResult(success=True, message='You are authorized')
@@ -59,12 +59,10 @@ def _handle_exception(context: click.Context, e: Exception):
5959

6060
errors: CliErrors = {
6161
AuthProcessError: CliError(
62-
code='auth_error',
63-
message='Authentication failed. Please try again later using the command `cycode auth`'
62+
code='auth_error', message='Authentication failed. Please try again later using the command `cycode auth`'
6463
),
6564
NetworkError: CliError(
66-
code='cycode_error',
67-
message='Authentication failed. Please try again later using the command `cycode auth`'
65+
code='cycode_error', message='Authentication failed. Please try again later using the command `cycode auth`'
6866
),
6967
}
7068

cycode/cli/auth/auth_manager.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,7 @@ def save_api_token(self, api_token: ApiToken):
8080
def _build_login_url(self, code_challenge: str, session_id: str):
8181
app_url = self.configuration_manager.get_cycode_app_url()
8282
login_url = f'{app_url}/account/sign-in'
83-
query_params = {
84-
'source': 'cycode_cli',
85-
'code_challenge': code_challenge,
86-
'session_id': session_id
87-
}
83+
query_params = {'source': 'cycode_cli', 'code_challenge': code_challenge, 'session_id': session_id}
8884
# TODO(MarshalX). Use auth_client instead and don't depend on "requests" lib here
8985
request = Request(url=login_url, params=query_params)
9086
return request.prepare().url
@@ -95,9 +91,12 @@ def _generate_pkce_code_pair(self) -> (str, str):
9591
return code_challenge, code_verifier
9692

9793
def _is_api_token_process_completed(self, api_token_polling_response: ApiTokenGenerationPollingResponse) -> bool:
98-
return api_token_polling_response is not None \
99-
and api_token_polling_response.status == self.COMPLETED_POLLING_STATUS
94+
return (
95+
api_token_polling_response is not None
96+
and api_token_polling_response.status == self.COMPLETED_POLLING_STATUS
97+
)
10098

10199
def _is_api_token_process_failed(self, api_token_polling_response: ApiTokenGenerationPollingResponse) -> bool:
102-
return api_token_polling_response is not None \
103-
and api_token_polling_response.status == self.FAILED_POLLING_STATUS
100+
return (
101+
api_token_polling_response is not None and api_token_polling_response.status == self.FAILED_POLLING_STATUS
102+
)

0 commit comments

Comments
 (0)