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
10 changes: 10 additions & 0 deletions .changeset/stupid-lines-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"evervault-python": major
---

- Deprecation of support for python versions 3.8 and 3.9.

### Migration from 4.x
- Python version must be >= python 3.10.
- There are no breaking API changes in the major release.

2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, 3.10.9, 3.11]
python-version: [3.10.18, 3.11, 3.12]
steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
python-version: 3.10.18
- name: Setup Poetry
uses: abatilo/actions-poetry@v2.1.2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, 3.10.9, 3.11]
python-version: [3.10.18, 3.11, 3.12]
steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion evervault/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def decrypt(self, data):
)
headers = self.__build_decrypt_headers(type(data))

if type(data) == bytes:
if isinstance(data, bytes):
return self.post("decrypt", data, headers, raise_errors_on_api_error)
else:
payload = {"data": data}
Expand Down
26 changes: 13 additions & 13 deletions evervault/crypto/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,32 +49,32 @@ def encrypt_data(self, fetch, data, role):
self.__fetch_cage_key(fetch)
self.shared_key = self.__derive_shared_key(role is not None)

if self.shared_key is None or type(self.shared_key) != bytes:
if self.shared_key is None or not isinstance(self.shared_key, bytes):
raise EvervaultError("Retrieved key is invalid")

if type(data) == bytes:
if isinstance(data, bytes):
return self.__encrypt_file(data, role)
elif type(data) == bytearray:
elif isinstance(data, bytearray):
return self.__encrypt_file(bytes(data), role)
elif type(data) == dict or type(data) == list or type(data) == set:
elif isinstance(data, dict) or isinstance(data, list) or isinstance(data, set):
return self.__traverse_and_encrypt(data, role)
elif self.__encryptable_data(data):
return self.__encrypt_string(data, role)
else:
raise EvervaultError(f"Cannot encrypt unsupported type {data}")

def __traverse_and_encrypt(self, data, role):
if type(data) == list:
if isinstance(data, list):
encrypted_list = []
for idx, item in enumerate(data):
if not self.__encryptable_data(item):
encrypted_list.insert(idx, self.__traverse_and_encrypt(item, role))
else:
encrypted_list.insert(idx, self.__encrypt_string(item, role))
return encrypted_list
elif type(data) == dict:
elif isinstance(data, dict):
return self.__encrypt_object(data, role)
elif type(data) == set:
elif isinstance(data, set):
return self.__encrypt_set(data, role)
elif self.__encryptable_data(data):
return self.__encrypt_string(data, role)
Expand Down Expand Up @@ -212,9 +212,9 @@ def __encrypt_file(self, data, role):
)

def __coerce_type(self, data):
if type(data) == bool:
if isinstance(data, bool):
return "true" if data else "false"
elif type(data) == int or type(data) == float:
elif isinstance(data, int) or isinstance(data, float):
return str(data)
else:
return data
Expand Down Expand Up @@ -254,10 +254,10 @@ def __base_64_remove_padding(self, data):

def __encryptable_data(self, data):
return data is not None and (
type(data) == str
or type(data) == bool
or type(data) == int
or type(data) == float
isinstance(data, str)
or isinstance(data, bool)
or isinstance(data, int)
or isinstance(data, float)
)

def __fetch_cage_key(self, fetch):
Expand Down
2 changes: 1 addition & 1 deletion evervault/http/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def __build_headers(self, method, params, url, optional_headers, version):

headers.update(optional_headers)
if method in ("POST", "PUT", "DELETE"):
if type(params) == bytes:
if isinstance(params, bytes):
req_params["data"] = params
else:
req_params["data"] = json.dumps(params, cls=json.JSONEncoder)
Expand Down
Loading