Skip to content

Commit 65201eb

Browse files
authored
running into weird ord bug in python3.11, lets do simpler 7 char hash (#79)
* running into weird ord bug in python3.11, lets do simpler 7 char hash * bump
1 parent 38827b6 commit 65201eb

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[flake8]
2-
ignore = E203,E303,E402,E501,E722,W391,F401,W292,F811
2+
ignore = E203,E303,E402,E501,E722,W391,F401,W292,F811,E302
33
max-line-length = 150
44
max-complexity = 22

polyapi/deployables.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import os
2+
import string
3+
import random
24
import subprocess
35
import json
46
import hashlib
@@ -76,9 +78,10 @@ class SyncDeployment(TypedDict, total=False):
7678
id: Optional[str]
7779
deployed: Optional[str]
7880

81+
7982
DeployableTypeEntries: List[Tuple[DeployableTypeNames, DeployableTypes]] = [
80-
("PolyServerFunction", "server-function"), # type: ignore
81-
("PolyClientFunction", "client-function"), # type: ignore
83+
("PolyServerFunction", "server-function"), # type: ignore
84+
("PolyClientFunction", "client-function"), # type: ignore
8285
]
8386

8487
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:
175178
return check_output(["git", "rev-parse", "--short", branch_or_tag], text=True).strip()
176179
except CalledProcessError:
177180
# Return a random 7-character hash as a fallback
178-
return "".join(format(ord(str(c)), 'x') for c in os.urandom(4))[:7]
181+
return "".join([random.choice(string.ascii_letters + string.digits) for _ in range(7)])
179182

180183
def get_cache_deployments_revision() -> str:
181184
"""Retrieve the cache deployments revision from a file."""

polyapi/sync.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ def read_file(file_path: str) -> str:
2424
return file.read()
2525

2626
def group_by(items: List[Dict], key: str) -> Dict[str, List[Dict]]:
27-
grouped = {}
27+
grouped = {} # type: ignore
2828
for item in items:
2929
grouped.setdefault(item[key], []).append(item)
3030
return grouped
3131

3232
def remove_deployable_function(deployable: SyncDeployment) -> bool:
3333
api_key, _ = get_api_key_and_url()
3434
if not api_key:
35-
raise Error("Missing api key!")
35+
raise Exception("Missing api key!")
3636
headers = get_auth_headers(api_key)
3737
url = f'{deployable["instance"]}/functions/{deployable["type"].replace("-function", "")}/{deployable["id"]}'
3838
response = requests.get(url, headers=headers)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["setuptools>=61.2", "wheel"]
33

44
[project]
55
name = "polyapi-python"
6-
version = "0.3.9.dev13"
6+
version = "0.3.9.dev14"
77
description = "The Python Client for PolyAPI, the IPaaS by Developers for Developers"
88
authors = [{ name = "Dan Fellin", email = "dan@polyapi.io" }]
99
dependencies = [

0 commit comments

Comments
 (0)