diff --git a/.flake8 b/.flake8 index da87de0..9e634cc 100644 --- a/.flake8 +++ b/.flake8 @@ -1,4 +1,4 @@ [flake8] -ignore = E203,E303,E402,E501,E722,W391,F401,W292,F811 +ignore = E203,E303,E402,E501,E722,W391,F401,W292,F811,E302 max-line-length = 150 max-complexity = 22 diff --git a/polyapi/deployables.py b/polyapi/deployables.py index 55dbbd7..fc0a6f3 100644 --- a/polyapi/deployables.py +++ b/polyapi/deployables.py @@ -1,4 +1,6 @@ import os +import string +import random import subprocess import json import hashlib @@ -76,9 +78,10 @@ class SyncDeployment(TypedDict, total=False): id: Optional[str] deployed: Optional[str] + DeployableTypeEntries: List[Tuple[DeployableTypeNames, DeployableTypes]] = [ - ("PolyServerFunction", "server-function"), # type: ignore - ("PolyClientFunction", "client-function"), # type: ignore + ("PolyServerFunction", "server-function"), # type: ignore + ("PolyClientFunction", "client-function"), # type: ignore ] DeployableTypeToName: Dict[DeployableTypeNames, DeployableTypes] = {name: type for name, type in DeployableTypeEntries} @@ -175,7 +178,7 @@ def get_git_revision(branch_or_tag: str = "HEAD") -> str: return check_output(["git", "rev-parse", "--short", branch_or_tag], text=True).strip() except CalledProcessError: # Return a random 7-character hash as a fallback - return "".join(format(ord(str(c)), 'x') for c in os.urandom(4))[:7] + return "".join([random.choice(string.ascii_letters + string.digits) for _ in range(7)]) def get_cache_deployments_revision() -> str: """Retrieve the cache deployments revision from a file.""" diff --git a/polyapi/sync.py b/polyapi/sync.py index 921defa..850538b 100644 --- a/polyapi/sync.py +++ b/polyapi/sync.py @@ -24,7 +24,7 @@ def read_file(file_path: str) -> str: return file.read() def group_by(items: List[Dict], key: str) -> Dict[str, List[Dict]]: - grouped = {} + grouped = {} # type: ignore for item in items: grouped.setdefault(item[key], []).append(item) return grouped @@ -32,7 +32,7 @@ def group_by(items: List[Dict], key: str) -> Dict[str, List[Dict]]: def remove_deployable_function(deployable: SyncDeployment) -> bool: api_key, _ = get_api_key_and_url() if not api_key: - raise Error("Missing api key!") + raise Exception("Missing api key!") headers = get_auth_headers(api_key) url = f'{deployable["instance"]}/functions/{deployable["type"].replace("-function", "")}/{deployable["id"]}' response = requests.get(url, headers=headers) diff --git a/pyproject.toml b/pyproject.toml index 02d26d7..e0a5b25 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ requires = ["setuptools>=61.2", "wheel"] [project] name = "polyapi-python" -version = "0.3.9.dev13" +version = "0.3.9.dev14" description = "The Python Client for PolyAPI, the IPaaS by Developers for Developers" authors = [{ name = "Dan Fellin", email = "dan@polyapi.io" }] dependencies = [