Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Black (code formatter)

on: [ pull_request, push ]

jobs:
black:
runs-on: ubuntu-latest

steps:
- name: Run Cimon
uses: cycodelabs/cimon-action@v0
with:
client-id: ${{ secrets.CIMON_CLIENT_ID }}
secret: ${{ secrets.CIMON_SECRET }}
prevent: true
allowed-hosts: >
files.pythonhosted.org
install.python-poetry.org
pypi.org

- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.7

- name: Setup Poetry
uses: snok/install-poetry@v1

- name: Install dependencies
run: poetry install

- name: Check code style of package
run: poetry run black --check cycode

- name: Check code style of tests
run: poetry run black --check tests
2 changes: 1 addition & 1 deletion cycode/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.0.0' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
__version__ = '0.0.0' # DON'T TOUCH. Placeholder. Will be filled automatically on poetry build from Git Tag
10 changes: 4 additions & 6 deletions cycode/cli/auth/auth_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@click.group(invoke_without_command=True)
@click.pass_context
def authenticate(context: click.Context):
""" Authenticates your machine to associate CLI with your cycode account """
"""Authenticates your machine to associate CLI with your cycode account"""
if context.invoked_subcommand is not None:
# if it is a subcommand do nothing
return
Expand All @@ -33,7 +33,7 @@ def authenticate(context: click.Context):
@authenticate.command(name='check')
@click.pass_context
def authorization_check(context: click.Context):
""" Check your machine associating CLI with your cycode account """
"""Check your machine associating CLI with your cycode account"""
printer = ConsolePrinter(context)

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

errors: CliErrors = {
AuthProcessError: CliError(
code='auth_error',
message='Authentication failed. Please try again later using the command `cycode auth`'
code='auth_error', message='Authentication failed. Please try again later using the command `cycode auth`'
),
NetworkError: CliError(
code='cycode_error',
message='Authentication failed. Please try again later using the command `cycode auth`'
code='cycode_error', message='Authentication failed. Please try again later using the command `cycode auth`'
),
}

Expand Down
17 changes: 8 additions & 9 deletions cycode/cli/auth/auth_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@ def save_api_token(self, api_token: ApiToken):
def _build_login_url(self, code_challenge: str, session_id: str):
app_url = self.configuration_manager.get_cycode_app_url()
login_url = f'{app_url}/account/sign-in'
query_params = {
'source': 'cycode_cli',
'code_challenge': code_challenge,
'session_id': session_id
}
query_params = {'source': 'cycode_cli', 'code_challenge': code_challenge, 'session_id': session_id}
# TODO(MarshalX). Use auth_client instead and don't depend on "requests" lib here
request = Request(url=login_url, params=query_params)
return request.prepare().url
Expand All @@ -95,9 +91,12 @@ def _generate_pkce_code_pair(self) -> (str, str):
return code_challenge, code_verifier

def _is_api_token_process_completed(self, api_token_polling_response: ApiTokenGenerationPollingResponse) -> bool:
return api_token_polling_response is not None \
and api_token_polling_response.status == self.COMPLETED_POLLING_STATUS
return (
api_token_polling_response is not None
and api_token_polling_response.status == self.COMPLETED_POLLING_STATUS
)

def _is_api_token_process_failed(self, api_token_polling_response: ApiTokenGenerationPollingResponse) -> bool:
return api_token_polling_response is not None \
and api_token_polling_response.status == self.FAILED_POLLING_STATUS
return (
api_token_polling_response is not None and api_token_polling_response.status == self.FAILED_POLLING_STATUS
)
Loading