Skip to content

Commit b79b9af

Browse files
committed
Fix ruff warnings
1 parent 08ab56a commit b79b9af

29 files changed

+139
-129
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
<p align="center">
10-
<a href="https://github.com/SynaLinks/synalinks" target="_blank"><strong>Documentation</strong></a> ·
10+
<a href="https://synalinks.github.io/synalinks" target="_blank"><strong>Documentation</strong></a> ·
1111
<a href="https://discord.gg/82nt97uXcM" target="_blank"><strong>Discord</strong></a> ·
1212
<a href="https://huggingface.co/spaces/YoanSallami/synalinks-noteboooks" target="_blank"><strong>Code Examples</strong></a>
1313
</p>

synalinks/api/backend/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from synalinks.src.backend import DataModel
88
from synalinks.src.backend.common.global_state import clear_session
9+
from synalinks.src.backend.common.json_data_model import is_json_data_model
910
from synalinks.src.backend.common.symbolic_data_model import is_symbolic_data_model
1011
from synalinks.src.backend.config import api_key
1112
from synalinks.src.backend.config import backend

synalinks/api/utils/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66

77
from synalinks.src.backend.common.global_state import clear_session
8+
from synalinks.src.backend.common.json_data_model import is_json_data_model
89
from synalinks.src.backend.common.symbolic_data_model import is_symbolic_data_model
910
from synalinks.src.backend.pydantic.core import is_meta_class
1011
from synalinks.src.saving.object_registration import CustomObjectScope

synalinks/src/backend/common/json_data_model.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ class Query(synalinks.DataModel):
6060
data_model=query_instance,
6161
)
6262
```
63-
63+
6464
**Creating a `JsonDataModel` with `to_json_data_model()`:**
65-
65+
6666
```python
6767
class Query(synalinks.DataModel):
6868
query: str = synalinks.Field(
6969
description="The user query",
7070
)
71-
71+
7272
data_model = Query(
7373
query="What is the capital of France?",
7474
).to_json_data_model()
@@ -184,7 +184,7 @@ def __radd__(self, other):
184184
"""Concatenates another data model with this one.
185185
186186
Args:
187-
other (JsonDataModel | DataModel):
187+
other (JsonDataModel | DataModel):
188188
The other data model to concatenate with.
189189
190190
Returns:
@@ -195,7 +195,7 @@ def __radd__(self, other):
195195
return asyncio.get_event_loop().run_until_complete(
196196
ops.Concat().call(other, self),
197197
)
198-
198+
199199
def __and__(self, other):
200200
"""Perform a `logical_and` with another data model.
201201
@@ -214,7 +214,7 @@ def __and__(self, other):
214214
return asyncio.get_event_loop().run_until_complete(
215215
ops.And().call(self, other),
216216
)
217-
217+
218218
def __rand__(self, other):
219219
"""Perform a `logical_and` (reverse) with another data model.
220220
@@ -233,7 +233,7 @@ def __rand__(self, other):
233233
return asyncio.get_event_loop().run_until_complete(
234234
ops.And().call(other, self),
235235
)
236-
236+
237237
def __or__(self, other):
238238
"""Perform a `logical_or` with another data model
239239
@@ -245,14 +245,15 @@ def __or__(self, other):
245245
246246
Returns:
247247
(JsonDataModel | None): The concatenation of data model if both are provided,
248-
or the non-None data model or None if none are provided. (See `logical_or` table).
248+
or the non-None data model or None if none are provided.
249+
(See `logical_or` table).
249250
"""
250251
from synalinks.src import ops
251252

252253
return asyncio.get_event_loop().run_until_complete(
253254
ops.Or().call(self, other),
254255
)
255-
256+
256257
def __ror__(self, other):
257258
"""Perform a `logical_or` (reverse) with another data model
258259
@@ -264,7 +265,8 @@ def __ror__(self, other):
264265
265266
Returns:
266267
(JsonDataModel | None): The concatenation of data model if both are provided,
267-
or the non-None data model or None if none are provided. (See `logical_or` table).
268+
or the non-None data model or None if none are provided.
269+
(See `logical_or` table).
268270
"""
269271
from synalinks.src import ops
270272

@@ -376,7 +378,7 @@ def __repr__(self):
376378
)
377379
def is_json_data_model(x):
378380
"""Returns whether `x` is a backend-independent data model.
379-
381+
380382
Args:
381383
x (any): The object to check.
382384

synalinks/src/backend/common/symbolic_data_model.py

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ class Query(synalinks.DataModel):
5656
5757
data_model = SymbolicDataModel(schema=Query.schema())
5858
```
59-
59+
6060
**Creating a `SymbolicDataModel` with `to_symbolic_data_model()`:**
61-
61+
6262
using a backend data model metaclass
63-
63+
6464
```python
6565
class Query(synalinks.DataModel):
6666
query: str = synalinks.Field(
@@ -127,22 +127,22 @@ def schema(self):
127127
(dict): The JSON schema.
128128
"""
129129
return self._schema
130-
130+
131131
def json(self, key):
132132
"""Alias for the JSON object's value (impossible in `SymbolicDataModel`).
133-
133+
134134
Implemented to help the user to identifying issues.
135-
135+
136136
Raises:
137137
ValueError: The help message.
138138
"""
139139
return self.value()
140-
140+
141141
def value(self):
142142
"""The current value of the JSON object (impossible in `SymbolicDataModel`).
143-
143+
144144
Implemented to help the user to identifying issues.
145-
145+
146146
Raises:
147147
ValueError: The help message.
148148
"""
@@ -203,7 +203,8 @@ def __and__(self, other):
203203
then concatenates this data model with the other.
204204
205205
Args:
206-
other (SymbolicDataModel | DataModel): The other data model to concatenate with.
206+
other (SymbolicDataModel | DataModel): The other data model to concatenate
207+
with.
207208
208209
Returns:
209210
(SymbolicDataModel | None): The concatenated data model or None
@@ -222,7 +223,8 @@ def __rand__(self, other):
222223
then concatenates the other data model with this one.
223224
224225
Args:
225-
other (SymbolicDataModel | DataModel): The other data model to concatenate with.
226+
other (SymbolicDataModel | DataModel): The other data model to concatenate
227+
with.
226228
227229
Returns:
228230
(SymbolicDataModel | None): The concatenated data model or None
@@ -244,8 +246,9 @@ def __or__(self, other):
244246
other (SymbolicDataModel): The other data model to concatenate with.
245247
246248
Returns:
247-
(SymbolicDataModel | None): The concatenation of data model if both are provided,
248-
or the non-None data model or None if none are provided. (See `logical_or` table).
249+
(SymbolicDataModel | None): The concatenation of data model if both are
250+
provided, or the non-None data model or None if none are provided.
251+
(See `logical_or` table).
249252
"""
250253
from synalinks.src import ops
251254

@@ -260,11 +263,13 @@ def __ror__(self, other):
260263
then concatenates the other data model with this one.
261264
262265
Args:
263-
other (SymbolicDataModel | DataModel): The other data model to concatenate with.
266+
other (SymbolicDataModel | DataModel): The other data model to concatenate
267+
with.
264268
265269
Returns:
266-
(SymbolicDataModel | None): The concatenation of data model if both are provided,
267-
or the non-None data model or None if none are provided. (See `logical_or` table).
270+
(SymbolicDataModel | None): The concatenation of data model if both are
271+
provided, or the non-None data model or None if none are provided.
272+
(See `logical_or` table).
268273
"""
269274
from synalinks.src import ops
270275

@@ -290,7 +295,7 @@ def in_mask(self, mask=None, recursive=True):
290295
Args:
291296
mask (list): The mask to be applied (list of keys).
292297
recursive (bool): Optional. Whether to apply the mask recursively.
293-
Defaults to True.
298+
Defaults to `True`.
294299
295300
Returns:
296301
(SymbolicDataModel): The data model with the mask applied.
@@ -307,7 +312,7 @@ def out_mask(self, mask=None, recursive=True):
307312
Args:
308313
mask (list): The mask to be applied (list of keys).
309314
recursive (bool): Optional. Whether to apply the mask recursively.
310-
Defaults to True.
315+
Defaults to `True`.
311316
312317
Returns:
313318
(SymbolicDataModel): The data model with the mask applied.
@@ -350,12 +355,12 @@ def suffix(self, suffix=None):
350355

351356
def get(self, key):
352357
"""Get wrapper to make easier to access fields.
353-
358+
354359
Implemented to help the user to identifying issues.
355360
356361
Args:
357362
key (str): The key to access.
358-
363+
359364
Raises:
360365
ValueError: The help message.
361366
"""
@@ -368,12 +373,12 @@ def get(self, key):
368373

369374
def update(self, kv_dict):
370375
"""Update wrapper to make easier to modify fields.
371-
376+
372377
Implemented to help the user to identifying issues.
373378
374379
Args:
375380
kv_dict (dict): The key/value dict to update.
376-
381+
377382
Raises:
378383
ValueError: The help message.
379384
"""

synalinks/src/backend/common/variables.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Variable:
2424
2525
A Variable is different from a JsonDataModel as it can be modified by the optimizers
2626
27-
Note that the DataModel used for the variable declaration
27+
Note that the DataModel used for the variable declaration
2828
**must have a default value** for each of its field.
2929
3030
Examples:

synalinks/src/backend/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def set_floatx(value):
5858
Instead, use `float64` or `float32`.
5959
6060
Args:
61-
value (str): The float type `'bfloat16'`, `'float16'`, `'float32'`, or `'float64'`.
61+
value (str): The float type between `'bfloat16'`, `'float16'`, `'float32'`,
62+
or `'float64'`.
6263
6364
Examples:
6465

0 commit comments

Comments
 (0)