Skip to content

Commit 1d778a6

Browse files
authored
Fix: Use of black was not enforced (#1)
1 parent dbab017 commit 1d778a6

File tree

13 files changed

+175
-148
lines changed

13 files changed

+175
-148
lines changed

.github/workflows/test-pytest.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,15 @@ jobs:
3030
- name: Cache the image on GitHub's repository
3131
run: docker tag aleph-client:${GITHUB_REF##*/} docker.pkg.github.com/$GITHUB_REPOSITORY/aleph-client-build-cache && docker push docker.pkg.github.com/$GITHUB_REPOSITORY/aleph-client-build-cache || true
3232

33-
- name: Pytest in the Docker image
33+
- name: Black in the Docker image
3434
run: |
35-
docker run --entrypoint /opt/venv/bin/pytest aleph-client:${GITHUB_REF##*/} /opt/aleph-client/
35+
docker run --entrypoint /opt/venv/bin/black aleph-client:${GITHUB_REF##*/} --check /opt/aleph-client/src
3636
3737
- name: MyPy in the Docker image
3838
run: |
3939
docker run --entrypoint /opt/venv/bin/mypy aleph-client:${GITHUB_REF##*/} --config-file /opt/aleph-client/mypy.ini /opt/aleph-client/src/ /opt/aleph-client/tests/ /opt/aleph-client/examples/
40+
41+
- name: Pytest in the Docker image
42+
run: |
43+
docker run --entrypoint /opt/venv/bin/pytest aleph-client:${GITHUB_REF##*/} /opt/aleph-client/
44+

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ testing =
7070
requests
7171
aleph-pytezos==0.1.0
7272
types-setuptools
73+
black
7374
mqtt =
7475
aiomqtt
7576
certifi

src/aleph_client/__main__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@
3131
aggregate.app, name="aggregate", help="Manage aggregate messages on Aleph.im"
3232
)
3333

34-
app.add_typer(
35-
account.app, name="account", help="Manage account"
36-
)
34+
app.add_typer(account.app, name="account", help="Manage account")
35+
3736

3837
@app.command()
3938
def whoami(

src/aleph_client/chains/common.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ def get_fallback_private_key(path: Optional[Path] = None) -> bytes:
8686
with open(path, "rb") as prvfile:
8787
print(prvfile.read())
8888

89-
9089
default_key_path = path.parent / "default.key"
9190
if not default_key_path.is_symlink():
9291
# Create a symlink to use this key by default

src/aleph_client/chains/sol.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,8 @@ def get_fallback_private_key(path: Optional[Path] = None) -> bytes:
7979
with open(path, "rb") as prvfile:
8080
print(prvfile.read())
8181

82-
8382
default_key_path = path.parent / "default.key"
8483
if not default_key_path.is_symlink():
8584
# Create a symlink to use this key by default
8685
os.symlink(path, default_key_path)
8786
return private_key
88-

src/aleph_client/commands/account.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717

1818
@app.command()
1919
def create(
20-
from_private_key: Optional[str] = typer.Option(
21-
None, help=help_strings.PRIVATE_KEY
22-
),
20+
from_private_key: Optional[str] = typer.Option(None, help=help_strings.PRIVATE_KEY),
2321
debug: bool = False,
2422
):
2523
"""Create or import a private key."""
2624

2725
setup_logging(debug)
2826

2927
typer.echo("Generating private key file.")
30-
private_key_file = typer.prompt("Enter file in which to save the key", settings.PRIVATE_KEY_FILE)
28+
private_key_file = typer.prompt(
29+
"Enter file in which to save the key", settings.PRIVATE_KEY_FILE
30+
)
3131

3232
if os.path.exists(private_key_file):
3333
typer.echo(f"Error: key already exists: '{private_key_file}'")

src/aleph_client/commands/message.py

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@
2929

3030
@app.command()
3131
def post(
32-
path: Optional[Path] = typer.Option(
33-
None,
34-
help="Path to the content you want to post. If omitted, you can input your content directly",
35-
),
36-
type: str = typer.Option("test", help="Text representing the message object type"),
37-
ref: Optional[str] = typer.Option(None, help=help_strings.REF),
38-
channel: str = typer.Option(settings.DEFAULT_CHANNEL, help=help_strings.CHANNEL),
39-
private_key: Optional[str] = typer.Option(
40-
settings.PRIVATE_KEY_STRING, help=help_strings.PRIVATE_KEY
41-
),
42-
private_key_file: Optional[Path] = typer.Option(
43-
settings.PRIVATE_KEY_FILE, help=help_strings.PRIVATE_KEY_FILE
44-
),
45-
debug: bool = False,
32+
path: Optional[Path] = typer.Option(
33+
None,
34+
help="Path to the content you want to post. If omitted, you can input your content directly",
35+
),
36+
type: str = typer.Option("test", help="Text representing the message object type"),
37+
ref: Optional[str] = typer.Option(None, help=help_strings.REF),
38+
channel: str = typer.Option(settings.DEFAULT_CHANNEL, help=help_strings.CHANNEL),
39+
private_key: Optional[str] = typer.Option(
40+
settings.PRIVATE_KEY_STRING, help=help_strings.PRIVATE_KEY
41+
),
42+
private_key_file: Optional[Path] = typer.Option(
43+
settings.PRIVATE_KEY_FILE, help=help_strings.PRIVATE_KEY_FILE
44+
),
45+
debug: bool = False,
4646
):
4747
"""Post a message on Aleph.im."""
4848

@@ -96,14 +96,14 @@ def post(
9696

9797
@app.command()
9898
def amend(
99-
hash: str = typer.Argument(..., help="Hash reference of the message to amend"),
100-
private_key: Optional[str] = typer.Option(
101-
settings.PRIVATE_KEY_STRING, help=help_strings.PRIVATE_KEY
102-
),
103-
private_key_file: Optional[Path] = typer.Option(
104-
settings.PRIVATE_KEY_FILE, help=help_strings.PRIVATE_KEY_FILE
105-
),
106-
debug: bool = False,
99+
hash: str = typer.Argument(..., help="Hash reference of the message to amend"),
100+
private_key: Optional[str] = typer.Option(
101+
settings.PRIVATE_KEY_STRING, help=help_strings.PRIVATE_KEY
102+
),
103+
private_key_file: Optional[Path] = typer.Option(
104+
settings.PRIVATE_KEY_FILE, help=help_strings.PRIVATE_KEY_FILE
105+
),
106+
debug: bool = False,
107107
):
108108
"""Amend an existing Aleph message."""
109109

@@ -141,10 +141,10 @@ def amend(
141141

142142

143143
def forget_messages(
144-
account: AccountFromPrivateKey,
145-
hashes: List[str],
146-
reason: Optional[str],
147-
channel: str,
144+
account: AccountFromPrivateKey,
145+
hashes: List[str],
146+
reason: Optional[str],
147+
channel: str,
148148
):
149149
try:
150150
result: ForgetMessage = synchronous.forget(
@@ -161,20 +161,20 @@ def forget_messages(
161161

162162
@app.command()
163163
def forget(
164-
hashes: str = typer.Argument(
165-
..., help="Comma separated list of hash references of messages to forget"
166-
),
167-
reason: Optional[str] = typer.Option(
168-
None, help="A description of why the messages are being forgotten."
169-
),
170-
channel: str = typer.Option(settings.DEFAULT_CHANNEL, help=help_strings.CHANNEL),
171-
private_key: Optional[str] = typer.Option(
172-
settings.PRIVATE_KEY_STRING, help=help_strings.PRIVATE_KEY
173-
),
174-
private_key_file: Optional[Path] = typer.Option(
175-
settings.PRIVATE_KEY_FILE, help=help_strings.PRIVATE_KEY_FILE
176-
),
177-
debug: bool = False,
164+
hashes: str = typer.Argument(
165+
..., help="Comma separated list of hash references of messages to forget"
166+
),
167+
reason: Optional[str] = typer.Option(
168+
None, help="A description of why the messages are being forgotten."
169+
),
170+
channel: str = typer.Option(settings.DEFAULT_CHANNEL, help=help_strings.CHANNEL),
171+
private_key: Optional[str] = typer.Option(
172+
settings.PRIVATE_KEY_STRING, help=help_strings.PRIVATE_KEY
173+
),
174+
private_key_file: Optional[Path] = typer.Option(
175+
settings.PRIVATE_KEY_FILE, help=help_strings.PRIVATE_KEY_FILE
176+
),
177+
debug: bool = False,
178178
):
179179
"""Forget an existing Aleph message."""
180180

@@ -188,9 +188,9 @@ def forget(
188188

189189
@app.command()
190190
def watch(
191-
ref: str = typer.Argument(..., help="Hash reference of the message to watch"),
192-
indent: Optional[int] = typer.Option(None, help="Number of indents to use"),
193-
debug: bool = False,
191+
ref: str = typer.Argument(..., help="Hash reference of the message to watch"),
192+
indent: Optional[int] = typer.Option(None, help="Number of indents to use"),
193+
debug: bool = False,
194194
):
195195
"""Watch a hash for amends and print amend hashes"""
196196

@@ -199,6 +199,6 @@ def watch(
199199
original: AlephMessage = synchronous.get_message(item_hash=ref)
200200

201201
for message in synchronous.watch_messages(
202-
refs=[ref], addresses=[original.content.address]
202+
refs=[ref], addresses=[original.content.address]
203203
):
204204
typer.echo(f"{message.json(indent=indent)}")

src/aleph_client/commands/program.py

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -36,62 +36,58 @@
3636

3737
@app.command()
3838
def upload(
39-
path: Path = typer.Argument(..., help="Path to your source code"),
40-
entrypoint: str = typer.Argument(..., help="Your program entrypoint"),
41-
channel: str = typer.Option(settings.DEFAULT_CHANNEL, help=help_strings.CHANNEL),
42-
memory: int = typer.Option(
43-
settings.DEFAULT_VM_MEMORY, help="Maximum memory allocation on vm in MiB"
44-
),
45-
vcpus: int = typer.Option(
46-
settings.DEFAULT_VM_VCPUS, help="Number of virtual cpus to allocate."
47-
),
48-
timeout_seconds: float = typer.Option(
49-
settings.DEFAULT_VM_TIMEOUT,
50-
help="If vm is not called after [timeout_seconds] it will shutdown",
51-
),
52-
private_key: Optional[str] = typer.Option(
53-
settings.PRIVATE_KEY_STRING, help=help_strings.PRIVATE_KEY
54-
),
55-
private_key_file: Optional[Path] = typer.Option(
56-
settings.PRIVATE_KEY_FILE, help=help_strings.PRIVATE_KEY_FILE
57-
),
58-
print_messages: bool = typer.Option(False),
59-
print_code_message: bool = typer.Option(False),
60-
print_program_message: bool = typer.Option(False),
61-
runtime: str = typer.Option(
62-
None,
63-
help="Hash of the runtime to use for your program. Defaults to aleph debian with Python3.8 and node. You can also create your own runtime and pin it",
64-
),
65-
beta: bool = typer.Option(False),
66-
67-
debug: bool = False,
68-
persistent: bool = False,
69-
persistent_volume: Optional[List[str]] = typer.Option(
70-
None,
71-
help='''Takes 3 parameters
39+
path: Path = typer.Argument(..., help="Path to your source code"),
40+
entrypoint: str = typer.Argument(..., help="Your program entrypoint"),
41+
channel: str = typer.Option(settings.DEFAULT_CHANNEL, help=help_strings.CHANNEL),
42+
memory: int = typer.Option(
43+
settings.DEFAULT_VM_MEMORY, help="Maximum memory allocation on vm in MiB"
44+
),
45+
vcpus: int = typer.Option(
46+
settings.DEFAULT_VM_VCPUS, help="Number of virtual cpus to allocate."
47+
),
48+
timeout_seconds: float = typer.Option(
49+
settings.DEFAULT_VM_TIMEOUT,
50+
help="If vm is not called after [timeout_seconds] it will shutdown",
51+
),
52+
private_key: Optional[str] = typer.Option(
53+
settings.PRIVATE_KEY_STRING, help=help_strings.PRIVATE_KEY
54+
),
55+
private_key_file: Optional[Path] = typer.Option(
56+
settings.PRIVATE_KEY_FILE, help=help_strings.PRIVATE_KEY_FILE
57+
),
58+
print_messages: bool = typer.Option(False),
59+
print_code_message: bool = typer.Option(False),
60+
print_program_message: bool = typer.Option(False),
61+
runtime: str = typer.Option(
62+
None,
63+
help="Hash of the runtime to use for your program. Defaults to aleph debian with Python3.8 and node. You can also create your own runtime and pin it",
64+
),
65+
beta: bool = typer.Option(False),
66+
debug: bool = False,
67+
persistent: bool = False,
68+
persistent_volume: Optional[List[str]] = typer.Option(
69+
None,
70+
help="""Takes 3 parameters
7271
A persistent volume is allocated on the host machine at any time
7372
eg: Use , to seperate the parameters and no spaces
7473
--persistent_volume persistence=host,name=my-volume,size=100 ./my-program main:app
75-
'''),
76-
77-
ephemeral_volume: Optional[List[str]] = typer.Option(
78-
None,
79-
help=
80-
'''Takes 1 parameter Only
74+
""",
75+
),
76+
ephemeral_volume: Optional[List[str]] = typer.Option(
77+
None,
78+
help="""Takes 1 parameter Only
8179
Ephemeral volumes can move and be removed by the host,Garbage collected basically, when the VM isn't running
8280
eg: Use , to seperate the parameters and no spaces
83-
--ephemeral-volume size_mib=100 ./my-program main:app '''),
84-
85-
immutable_volume: Optional[List[str]] = typer.Option(
86-
None,
87-
help=
88-
'''Takes 3 parameters
81+
--ephemeral-volume size_mib=100 ./my-program main:app """,
82+
),
83+
immutable_volume: Optional[List[str]] = typer.Option(
84+
None,
85+
help="""Takes 3 parameters
8986
Immutable volume is one whose contents do not change
9087
eg: Use , to seperate the parameters and no spaces
9188
--immutable-volume ref=25a393222692c2f73489dc6710ae87605a96742ceef7b91de4d7ec34bb688d94,use_latest=true,mount=/mnt/volume ./my-program main:app
92-
'''
93-
)
94-
89+
""",
90+
),
9591
):
9692
"""Register a program to run on Aleph.im virtual machines from a zip archive."""
9793

@@ -111,15 +107,19 @@ def upload(
111107
account: AccountFromPrivateKey = _load_account(private_key, private_key_file)
112108

113109
runtime = (
114-
runtime
115-
or input(f"Ref of runtime ? [{settings.DEFAULT_RUNTIME_ID}] ")
116-
or settings.DEFAULT_RUNTIME_ID
110+
runtime
111+
or input(f"Ref of runtime ? [{settings.DEFAULT_RUNTIME_ID}] ")
112+
or settings.DEFAULT_RUNTIME_ID
117113
)
118114

119115
volumes = []
120116

121117
# Check if the volumes are empty
122-
if persistent_volume is None or ephemeral_volume is None or immutable_volume is None:
118+
if (
119+
persistent_volume is None
120+
or ephemeral_volume is None
121+
or immutable_volume is None
122+
):
123123
for volume in prompt_for_volumes():
124124
volumes.append(volume)
125125
typer.echo("\n")
@@ -211,12 +211,12 @@ def upload(
211211

212212
@app.command()
213213
def update(
214-
hash: str,
215-
path: Path,
216-
private_key: Optional[str] = settings.PRIVATE_KEY_STRING,
217-
private_key_file: Optional[Path] = settings.PRIVATE_KEY_FILE,
218-
print_message: bool = True,
219-
debug: bool = False,
214+
hash: str,
215+
path: Path,
216+
private_key: Optional[str] = settings.PRIVATE_KEY_STRING,
217+
private_key_file: Optional[Path] = settings.PRIVATE_KEY_FILE,
218+
print_message: bool = True,
219+
debug: bool = False,
220220
):
221221
"""Update the code of an existing program"""
222222

@@ -274,10 +274,10 @@ def update(
274274

275275
@app.command()
276276
def unpersist(
277-
hash: str,
278-
private_key: Optional[str] = settings.PRIVATE_KEY_STRING,
279-
private_key_file: Optional[Path] = settings.PRIVATE_KEY_FILE,
280-
debug: bool = False,
277+
hash: str,
278+
private_key: Optional[str] = settings.PRIVATE_KEY_STRING,
279+
private_key_file: Optional[Path] = settings.PRIVATE_KEY_FILE,
280+
debug: bool = False,
281281
):
282282
"""Stop a persistent virtual machine by making it non-persistent"""
283283

src/aleph_client/commands/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,9 @@ def volume_to_dict(volume: List[str]) -> Optional[Dict[str, Union[str, int]]]:
8080
p = param.split("=")
8181
if p[1].isdigit():
8282
dict_store[p[0]] = int(p[1])
83-
elif p[1] in ['True', 'true', 'False', 'false']:
83+
elif p[1] in ["True", "true", "False", "false"]:
8484
dict_store[p[0]] = bool(p[1].capitalize())
8585
else:
8686
dict_store[p[0]] = p[1]
8787

8888
return dict_store
89-

0 commit comments

Comments
 (0)