Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use tomllib instead of PyPI toml on Python 3.11 and later #115

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ dependencies = [
"click>=8.1.4",
"executing>=2.1.0",
"rich>=13.7.1",
"toml>=0.10.2",
"types-toml>=0.10.8.7",
"toml>=0.10.2; python_version < '3.11'",
"types-toml>=0.10.8.7; python_version < '3.11'",
"typing-extensions"
]
description = "golden master/snapshot/approval testing library which puts the values right into your source code"
Expand Down
8 changes: 6 additions & 2 deletions src/inline_snapshot/_config.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import os
import sys
from dataclasses import dataclass
from dataclasses import field
from pathlib import Path
from typing import List

import toml
if sys.version_info >= (3, 11):
from tomllib import loads
else:
from toml import loads


@dataclass
Expand All @@ -20,7 +24,7 @@ def read_config(path: Path) -> Config:
result = Config()
if path.exists():

data = toml.loads(path.read_text("utf-8"))
data = loads(path.read_text("utf-8"))

try:
config = data["tool"]["inline-snapshot"]
Expand Down