Skip to content
Open
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
10 changes: 7 additions & 3 deletions bundle/l10n.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
import re
import shutil
import subprocess
import sys
from pathlib import Path

import toml
if sys.version_info >= (3, 11):
import tomllib
else:
import tomli as tomllib
from babel.messages.frontend import CommandLineInterface

LOCALES_PATH = Path(__file__).resolve().parents[1] / "normcap" / "resources" / "locales"
Expand All @@ -24,9 +28,9 @@ def _get_version() -> str:
except Exception:
print("Could not import __version__. Fallback to pyproject.toml.") # noqa: T201
with (Path(__file__).resolve().parents[1] / "pyproject.toml").open(
encoding="utf8"
"b", encoding="utf8"
) as toml_file:
pyproject_toml = toml.load(toml_file)
pyproject_toml = tomllib.load(toml_file)
version = pyproject_toml["tool"]["briefcase"]["version"]

return version
Expand Down
9 changes: 6 additions & 3 deletions bundle/platforms/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
from pathlib import Path
from textwrap import dedent

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


Expand Down Expand Up @@ -88,8 +91,8 @@ def get_version(self) -> str:
if "--dev" in sys.argv:
return "0.0.1"

with Path(self.PYPROJECT_PATH).open(encoding="utf8") as toml_file:
pyproject_toml = toml.load(toml_file)
with Path(self.PYPROJECT_PATH).open("b", encoding="utf8") as toml_file:
pyproject_toml = tomllib.load(toml_file)
return pyproject_toml["project"]["version"]

@staticmethod
Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies = [
]

[project.optional-dependencies]
build = [ "babel", "toml" ]
build = [ "babel", "tomli"]

[project.urls]
Homepage = "https://dynobo.github.io/normcap/"
Expand Down Expand Up @@ -78,9 +78,8 @@ dev = [
"rope>=1.7.0",
"ruff>=0.0.239",
"tbump>=6.9.0",
"toml>=0.10.2",
"tomli>=2.0.1; python_version < '3.11'",
"types-retry>=0.9.9.4",
"types-toml>=0.10.8.1",
"typing-extensions>=4.4.0",
"poethepoet>=0.29.0",
]
Expand Down
10 changes: 7 additions & 3 deletions tests/test_app.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import logging
import sys
from pathlib import Path

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

import normcap

logger = logging.getLogger(__name__)


def test_version():
with Path("pyproject.toml").open(encoding="utf8") as toml_file:
pyproject_toml = toml.load(toml_file)
with Path("pyproject.toml").open("b", encoding="utf8") as toml_file:
pyproject_toml = tomllib.load(toml_file)

pyproject_version = pyproject_toml["project"]["version"]
normcap_version = normcap.__version__
Expand Down