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

Remove TOML dependency #82

Merged
merged 2 commits into from
Sep 13, 2023
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
6 changes: 3 additions & 3 deletions metricity/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import asyncio
import logging
import os
import tomllib
from pathlib import Path
from typing import TYPE_CHECKING

import coloredlogs
import toml
from pydis_core.utils import apply_monkey_patches

from metricity.config import PythonConfig
Expand All @@ -16,8 +16,8 @@
from metricity.bot import Bot

# Read the version from the pyproject.toml file.
with Path.open("pyproject.toml") as f:
package_vers = toml.load(f)["tool"]["poetry"]["version"]
with Path.open("pyproject.toml", "rb") as f:
package_vers = tomllib.load(f)["tool"]["poetry"]["version"]

__version__ = package_vers

Expand Down
10 changes: 5 additions & 5 deletions metricity/config.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Configuration reader for Metricity."""
import logging
import tomllib
from os import environ
from pathlib import Path
from typing import Any

import toml
from deepmerge import Merger
from dotenv import load_dotenv

Expand All @@ -29,16 +29,16 @@ def get_section(section: str) -> dict[str, Any]:
if not default_config_file.exists():
raise MetricityConfigurationError("config-default.toml is missing")

with default_config_file.open() as default_config_file:
default_config = toml.load(default_config_file)
with default_config_file.open("rb") as default_config_file:
default_config = tomllib.load(default_config_file)

# Load user configuration
user_config = {}
user_config_location = Path(environ.get("CONFIG_LOCATION", "./config.toml"))

if user_config_location.exists():
with Path.open(user_config_location) as user_config_file:
user_config = toml.load(user_config_file)
with Path.open(user_config_location, "rb") as user_config_file:
user_config = tomllib.load(user_config_file)

# Merge the configuration
merger = Merger(
Expand Down
45 changes: 12 additions & 33 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ coloredlogs = "15.0.1"
deepmerge = "1.1.0"
sqlalchemy = { extras = ["asyncio"], version = "2.0.20" }
python-dotenv = "1.0.0"
toml = "0.10.2"
asyncpg = "0.28.0"

[tool.poetry.dev-dependencies]
Expand Down