Skip to content

Commit fdd9255

Browse files
authored
Merge pull request #272 from Moustachauve/change-yaml-library
Change yaml library from ruyaml to pyyaml
2 parents c7945ef + 6c01e40 commit fdd9255

File tree

4 files changed

+70
-52
lines changed

4 files changed

+70
-52
lines changed

poetry.lock

Lines changed: 58 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyhilo/util/state.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import Any, Optional, Type, TypedDict, TypeVar, Union
55

66
import aiofiles
7-
import ruyaml as yaml
7+
import yaml
88

99
from pyhilo.const import LOG
1010

@@ -42,7 +42,8 @@ class RegistrationDict(TypedDict, total=False):
4242

4343
class FirebaseDict(TypedDict):
4444
fid: Optional[str]
45-
name: Optional[str] # "projects/18450192328/installations/d7N8yHopRWOiTYCrnYLi8a"
45+
# "projects/18450192328/installations/d7N8yHopRWOiTYCrnYLi8a"
46+
name: Optional[str]
4647
token: TokenDict
4748

4849

@@ -108,9 +109,15 @@ async def set_state(
108109
"""
109110
async with lock: # note ic-dev21: on lock le fichier pour être sûr de finir la job
110111
current_state = await get_state(state_yaml) or {}
111-
merged_state: dict[str, Any] = {key: {**current_state.get(key, {}), **state}} # type: ignore
112+
merged_state: dict[str, Any] = {
113+
key: {**current_state.get(key, {}), **state}
114+
} # type: ignore
112115
new_state: dict[str, Any] = {**current_state, **merged_state}
113116
async with aiofiles.open(state_yaml, mode="w") as yaml_file:
114117
LOG.debug("Saving state to yaml file")
118+
# TODO: Use asyncio.get_running_loop() and run_in_executor to write
119+
# to the file in a non blocking manner. Currently, the file writes
120+
# are properly async but the yaml dump is done synchroniously on the
121+
# main event loop.
115122
content = yaml.dump(new_state)
116123
await yaml_file.write(content)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ async-timeout = ">=4.0.0"
7171
attrs = ">=21.2.0"
7272
backoff = ">=1.11.1"
7373
python-dateutil = ">=2.8.2"
74-
ruyaml = ">=0.91.0"
7574
python = "^3.9.0"
7675
voluptuous = ">=0.13.1"
7776
websockets = ">=8.1,<16.0"
7877
gql = "^3.5.2"
78+
pyyaml = "^6.0.2"
7979

8080
[poetry.group.dev.dependencies]
8181
Sphinx = "^7.1.2"

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ frozenlist>=1.3.3
1010
idna>=3.4
1111
multidict>=6.0.4
1212
python-dateutil>=2.8.2
13-
ruyaml>=0.91.0
13+
pyyaml>=6.0.2
1414
six>=1.16.0
1515
typing_extensions>=4.5.0
1616
yarl>=1.8.2

0 commit comments

Comments
 (0)