From 4f28955535ca3c334b001299d46bd36f21f3bd62 Mon Sep 17 00:00:00 2001 From: 0x6f677548 <64972114+0x6f677548@users.noreply.github.com> Date: Wed, 25 Oct 2023 06:34:09 +0100 Subject: [PATCH] chore: lint cleaning --- pyproject.toml | 3 ++- src/ca_pwt/authentication.py | 5 +++-- src/ca_pwt/commands.py | 2 +- src/ca_pwt/helpers/graph_api.py | 2 +- src/ca_pwt/helpers/utils.py | 5 ++++- tests/test_data.py | 4 ++-- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9614876..9a5bb8a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,7 +33,8 @@ classifiers = [ dependencies = [ "requests>=2.31.0", "msal>=1.24.1", - "click>=8.1.7" + "click>=8.1.7", + "types-requests>=2.31.0", ] [project.scripts] diff --git a/src/ca_pwt/authentication.py b/src/ca_pwt/authentication.py index 955721f..17ce2ea 100644 --- a/src/ca_pwt/authentication.py +++ b/src/ca_pwt/authentication.py @@ -1,4 +1,5 @@ import logging +from typing import Callable from msal import PublicClientApplication, ConfidentialClientApplication _common_tenant_id = "common" @@ -138,8 +139,8 @@ def acquire_token_by_username_password( def acquire_token_by_device_flow( - stdout_callback: callable, - stdout_flush: callable, + stdout_callback: Callable, + stdout_flush: Callable, client_id: str = _default_client_id, tenant_id: str = _common_tenant_id, scopes: list[str] = _default_scopes, diff --git a/src/ca_pwt/commands.py b/src/ca_pwt/commands.py index ee06fbe..addccf1 100644 --- a/src/ca_pwt/commands.py +++ b/src/ca_pwt/commands.py @@ -453,7 +453,7 @@ def import_groups_cmd( input_file = _get_from_ctx_if_none(ctx, "output_file", input_file, lambda: click.prompt("The input file")) click.echo(f"Input file: {input_file}") groups = load_groups(input_file) - created_groups = import_groups(access_token, groups, allow_duplicates) + created_groups = import_groups(access_token, groups, allow_duplicates=allow_duplicates) click.echo("Successfully created groups:") for group in created_groups: click.echo(f"{group[0]}: {group[1]}") diff --git a/src/ca_pwt/helpers/graph_api.py b/src/ca_pwt/helpers/graph_api.py index d4bf527..4de7524 100644 --- a/src/ca_pwt/helpers/graph_api.py +++ b/src/ca_pwt/helpers/graph_api.py @@ -19,7 +19,7 @@ def __init__(self, request_response: requests.Response, expected_status_code: in the success property will be set to True """ self.status_code = request_response.status_code - self.response = request_response + self.response: requests.Response | str = request_response self.expected_status_code = expected_status_code self.success = self.status_code == self.expected_status_code if self._logger.isEnabledFor(logging.DEBUG): diff --git a/src/ca_pwt/helpers/utils.py b/src/ca_pwt/helpers/utils.py index d169d3c..7d8f6bf 100644 --- a/src/ca_pwt/helpers/utils.py +++ b/src/ca_pwt/helpers/utils.py @@ -1,4 +1,7 @@ -def assert_condition(condition: any, message: str): +from typing import Any + + +def assert_condition(condition: Any, message: str): """Asserts a condition and raises an AssertionError if it is False""" if not condition: raise AssertionError(message) diff --git a/tests/test_data.py b/tests/test_data.py index 2ad8f13..e5c16a2 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -1,5 +1,5 @@ # flake8: noqa: E501 -valid_policies: dict = [ +valid_policies: list[dict] = [ { "id": "88ef8435-6ab4-42c5-8e8d-e5dc2d1d66a9", "displayName": "TEST-POLICY", @@ -41,7 +41,7 @@ } ] -invalid_policies: dict = [ +invalid_policies: list[dict] = [ { "displayNames": "ca-test", "conditions": {