Update to Python 3.12
* Remove toml dependency since that comes with Python as of 3.11 * Update toml usage to tomllib in config.py * Update `with open(...)` for toml file reading to be 'rb' * Update Pipfile.lock for locked dependencies to work with Python 3.12 Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
FROM "python:3.10-alpine"
|
FROM "python:3.12-alpine"
|
||||||
STOPSIGNAL SIGINT
|
STOPSIGNAL SIGINT
|
||||||
RUN mkdir /app
|
RUN mkdir /app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|||||||
3
Pipfile
3
Pipfile
@@ -5,7 +5,6 @@ name = "pypi"
|
|||||||
|
|
||||||
[packages]
|
[packages]
|
||||||
async-irc = "*"
|
async-irc = "*"
|
||||||
toml = {version="*", markers="python_version < '3.11'"}
|
|
||||||
types-toml = "*"
|
types-toml = "*"
|
||||||
"aiohttp[speedups]" = "*"
|
"aiohttp[speedups]" = "*"
|
||||||
async-timeout = ">=4"
|
async-timeout = ">=4"
|
||||||
@@ -15,7 +14,7 @@ mypy = "*"
|
|||||||
black = "*"
|
black = "*"
|
||||||
|
|
||||||
[requires]
|
[requires]
|
||||||
python_version = "3.10"
|
python_version = "3.12"
|
||||||
|
|
||||||
[pipenv]
|
[pipenv]
|
||||||
allow_prereleases = true
|
allow_prereleases = true
|
||||||
|
|||||||
1238
Pipfile.lock
generated
1238
Pipfile.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -36,7 +36,7 @@ config_path = Path(args.config or os.environ.get("OMNIBOT_CONFIG", "config.toml"
|
|||||||
config = ServerConfig()
|
config = ServerConfig()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(config_path) as fp:
|
with open(config_path, 'rb') as fp:
|
||||||
config.load(fp)
|
config.load(fp)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print(f"ERROR: config file not found: {config_path}", file=sys.stderr)
|
print(f"ERROR: config file not found: {config_path}", file=sys.stderr)
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
import dataclasses
|
import dataclasses
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import IO, Any, Mapping, Sequence, Set
|
from typing import IO, Any, Mapping, Sequence, Set
|
||||||
|
import tomllib
|
||||||
import toml
|
|
||||||
|
|
||||||
|
|
||||||
PluginConfig = Mapping[str, Any]
|
PluginConfig = Mapping[str, Any]
|
||||||
@@ -34,7 +33,7 @@ class ServerConfig:
|
|||||||
loglevel: str | None = None
|
loglevel: str | None = None
|
||||||
|
|
||||||
def load(self, fp: IO[str]):
|
def load(self, fp: IO[str]):
|
||||||
obj = toml.load(fp)
|
obj = tomllib.load(fp)
|
||||||
|
|
||||||
if "server" not in obj:
|
if "server" not in obj:
|
||||||
raise ConfigError("server", "must be present")
|
raise ConfigError("server", "must be present")
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ async def main():
|
|||||||
channel = sys.argv[1]
|
channel = sys.argv[1]
|
||||||
files = sys.argv[2:]
|
files = sys.argv[2:]
|
||||||
server_config = ServerConfig()
|
server_config = ServerConfig()
|
||||||
with open("config.toml") as fp:
|
with open("config.toml", 'rb') as fp:
|
||||||
server_config.load(fp)
|
server_config.load(fp)
|
||||||
# This only works on one plugin per config
|
# This only works on one plugin per config
|
||||||
bot = Bot(server_config)
|
bot = Bot(server_config)
|
||||||
|
|||||||
Reference in New Issue
Block a user