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
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -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
9 changes: 6 additions & 3 deletions polyapi/deployables.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os
import string
import random
import subprocess
import json
import hashlib
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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."""
Expand Down
4 changes: 2 additions & 2 deletions polyapi/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ 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

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)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
Loading