Skip to content

Commit 420a56f

Browse files
authored
Merge pull request #12 from robert-nogueira/main
Refactor and Improve Type Hints, Clean Up Code, and Remove requests Attribute from StatusData
2 parents 2a8e219 + a9f6fed commit 420a56f

File tree

73 files changed

+2275
-1221
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+2275
-1221
lines changed

.safety-project.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[project]
2+
id = sdk-api-py
3+
url = /projects/dfc17c5f-6abc-4165-8c26-32954be241e9/findings
4+
name = sdk-api-py

examples/app_cache/accessing_application_cache.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import asyncio
2+
13
import squarecloud as square
24

35
client = square.Client('API_KEY')
46

57

6-
async def example():
8+
async def example() -> None:
79
app = await client.app('application_id')
810

911
# See that since no request was made, the cache is empty
@@ -20,3 +22,6 @@ async def example():
2022
print(app.cache.status) # StatusData(...)
2123
print(app.cache.logs) # LogsData(...)
2224
print(app.cache.backup) # BackupData(...)
25+
26+
27+
asyncio.run(example())

examples/app_cache/avoid_update_cache.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import asyncio
2+
13
import squarecloud as square
24

35
client = square.Client('API_KEY')
46

57

6-
async def example():
8+
async def example() -> None:
79
app = await client.app('application_id')
810

911
# below we are setting "update_cache" to False,
@@ -16,3 +18,6 @@ async def example():
1618
print(app.cache.status) # None
1719
print(app.cache.logs) # None
1820
print(app.cache.backup) # None
21+
22+
23+
asyncio.run(example())

examples/app_cache/clear_cache.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import asyncio
2+
13
import squarecloud as square
24

35
client = square.Client('API_KEY')
46

57

6-
async def example():
8+
async def example() -> None:
79
app = await client.app('application_id')
810

911
await app.status()
@@ -19,3 +21,6 @@ async def example():
1921
print(app.cache.status) # None
2022
print(app.cache.logs) # None
2123
print(app.cache.backup) # None
24+
25+
26+
asyncio.run(example())

examples/app_cache/update_cache.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import asyncio
2+
13
import squarecloud as square
24

35
client = square.Client('API_KEY')
46

57

6-
async def example():
8+
async def example() -> None:
79
app = await client.app('application_id')
810

911
status = await app.status()
@@ -17,3 +19,6 @@ async def example():
1719
print(app.cache.status) # StatusData(...)
1820
print(app.cache.logs) # LogsData(...)
1921
print(app.cache.backup) # BackupData(...)
22+
23+
24+
asyncio.run(example())

examples/app_data/with_application.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

examples/app_data/with_client.py

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
import asyncio
2+
13
import squarecloud as square
24

35
client = square.Client(api_key='API KEY')
46

57

6-
async def example():
8+
async def example() -> None:
79
app = await client.app('application_id')
810
backup = await app.backup()
911
print(backup.downloadURL) # https://squarecloud.app/dashboard/backup/f.zip
12+
13+
14+
asyncio.run(example())

examples/backup/with_client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
import asyncio
2+
13
import squarecloud as square
24

35
client = square.Client(api_key='API KEY')
46

57

6-
async def example():
8+
async def example() -> None:
79
backup = await client.backup('application_id')
810
print(backup.downloadURL) # https://squarecloud.app/dashboard/backup/f.zip
11+
12+
13+
asyncio.run(example())

examples/capture_listener.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
1-
import squarecloud
1+
import asyncio
2+
23
import squarecloud as square
34
from squarecloud import Endpoint
45

56
client = square.Client('API_KEY', debug=False)
67

78

8-
async def example():
9+
async def example() -> None:
910
app = await client.app('application_id')
1011

1112
@app.capture(endpoint=Endpoint.logs())
12-
async def on_logs_request(before: squarecloud.E, after):
13+
async def on_logs_request(
14+
before: square.LogsData, after: square.LogsData
15+
) -> None:
1316
if after != before:
1417
print(f'New logs!!! {after}')
1518

1619
await app.logs() # True
17-
1820
await app.logs() # False
21+
22+
23+
asyncio.run(example())

0 commit comments

Comments
 (0)