File: 0002-remove-toml.patch

package info (click to toggle)
python-maison 2.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 484 kB
  • sloc: python: 817; makefile: 12; sh: 5
file content (57 lines) | stat: -rw-r--r-- 1,526 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
--- a/src/maison/config_sources/toml_source.py
+++ b/src/maison/config_sources/toml_source.py
@@ -1,11 +1,10 @@
 """Module to hold the `TomlSource` class definition."""
 
+import tomllib
 from functools import lru_cache
 from typing import Any
 from typing import Dict
 
-import toml
-
 from ..errors import BadTomlError
 from .base_source import BaseSource
 
@@ -32,8 +31,9 @@
             BadTomlError: If toml cannot be parsed
         """
         try:
-            return dict(toml.load(self.filepath))
-        except toml.decoder.TomlDecodeError as exc:
+            with open(self.filepath, 'rb') as fd:
+                return dict(tomllib.load(fd))
+        except tomllib.TOMLDecodeError as exc:
             raise BadTomlError(
                 f"Error trying to load toml file '{self.filepath}'"
             ) from exc
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -7,7 +7,7 @@
 from typing import Optional
 
 import pytest
-import toml
+import tomli_w
 
 
 @pytest.fixture(name="create_tmp_file")
@@ -31,7 +31,7 @@
         content: Optional[Dict[str, Any]] = None,
     ) -> Path:
         content = content or {}
-        config_toml = toml.dumps(content)
+        config_toml = tomli_w.dumps(content)
         return create_tmp_file(content=config_toml, filename=filename)
 
     return _create_toml
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -24,7 +24,6 @@
 [tool.poetry.dependencies]
 python = "^3.9.1"
 click = "^8.0.1"
-toml = "^0.10.2"
 
 [tool.poetry.group.test.dependencies]
 pytest = "^8.3.0"