Skip to content

Commit 9f985ab

Browse files
committed
Replace third-party tomlkit with stdlib tomllib
1 parent bce1bed commit 9f985ab

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

build_docs.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
from urllib.parse import urljoin
4949

5050
import jinja2
51-
import tomlkit
51+
import tomllib
5252
import urllib3
5353
import zc.lockfile
5454

@@ -915,7 +915,7 @@ def should_rebuild(self):
915915
def load_state(self) -> dict:
916916
state_file = self.build_root / "state.toml"
917917
try:
918-
return tomlkit.loads(state_file.read_text(encoding="UTF-8"))[
918+
return tomllib.loads(state_file.read_text(encoding="UTF-8"))[
919919
f"/{self.language.tag}/{self.version.name}/"
920920
]
921921
except (KeyError, FileNotFoundError):
@@ -928,9 +928,9 @@ def save_state(self, build_duration: float):
928928
"""
929929
state_file = self.build_root / "state.toml"
930930
try:
931-
states = tomlkit.parse(state_file.read_text(encoding="UTF-8"))
931+
states = tomllib.parse(state_file.read_text(encoding="UTF-8"))
932932
except FileNotFoundError:
933-
states = tomlkit.document()
933+
states = tomllib.document()
934934

935935
state = {}
936936
state["cpython_sha"] = self.cpython_repo.run("rev-parse", "HEAD").stdout.strip()
@@ -941,7 +941,7 @@ def save_state(self, build_duration: float):
941941
state["last_build"] = dt.now(timezone.utc)
942942
state["last_build_duration"] = build_duration
943943
states[f"/{self.language.tag}/{self.version.name}/"] = state
944-
state_file.write_text(tomlkit.dumps(states), encoding="UTF-8")
944+
state_file.write_text(tomllib.dumps(states), encoding="UTF-8")
945945

946946

947947
def symlink(
@@ -1092,7 +1092,7 @@ def parse_versions_from_devguide(http: urllib3.PoolManager) -> list[Version]:
10921092

10931093
def parse_languages_from_config() -> list[Language]:
10941094
"""Read config.toml to discover languages to build."""
1095-
config = tomlkit.parse((HERE / "config.toml").read_text(encoding="UTF-8"))
1095+
config = tomllib.parse((HERE / "config.toml").read_text(encoding="UTF-8"))
10961096
languages = []
10971097
defaults = config["defaults"]
10981098
for iso639_tag, section in config["languages"].items():

requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
jinja2
22
sentry-sdk>=2
3-
tomlkit
43
urllib3>=2
54
zc.lockfile

0 commit comments

Comments
 (0)