Skip to content

Commit 28ffcff

Browse files
authored
Add Python 3.13 support (#201)
* feat:try python3.13 * fix: mypy errors * fix: trigger python3.11 release * fix:broken test due to broken endpoint * fix: make code modern * fix: latest build * fix: bye bye py 3.9 👋🏻 * fix: new major release * fix: add python3.12
1 parent 0531aff commit 28ffcff

File tree

6 files changed

+11
-19
lines changed

6 files changed

+11
-19
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
python-version: [3.8, 3.9, pypy-3.8, pypy-3.9, pypy-3.10, '3.10', '3.11' , '3.12.0']
15+
python-version: [pypy-3.10, '3.10', '3.11' , '3.12', '3.13']
1616
os: [
1717
ubuntu-latest,
1818
windows-latest,
19-
macos-13,
19+
macos-latest,
2020
]
2121

2222
steps:
@@ -25,6 +25,7 @@ jobs:
2525
uses: actions/setup-python@v4
2626
with:
2727
python-version: ${{ matrix.python-version }}
28+
allow-prereleases: true
2829
- name: Install dependencies
2930
run: |
3031
python -m pip install --upgrade pip

json2xml/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
__author__ = """Vinit Kumar"""
44
__email__ = "[email protected]"
5-
__version__ = "4.1.0"
5+
__version__ = "5.0.0"

json2xml/dicttoxml.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ def get_unique_id(element: str) -> str:
5959
float,
6060
bool,
6161
numbers.Number,
62-
Sequence,
62+
Sequence[str],
6363
datetime.datetime,
6464
datetime.date,
6565
None,
66-
Dict[str, Any],
66+
dict[str, Any],
6767
]
6868

6969

json2xml/json2xml.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Json2xml:
1414
"""
1515
def __init__(
1616
self,
17-
data: Optional[Dict[str, Any]] = None,
17+
data: dict[str, Any] | None = None,
1818
wrapper: str = "all",
1919
root: bool = True,
2020
pretty: bool = True,
@@ -28,7 +28,7 @@ def __init__(
2828
self.root = root
2929
self.item_wrap = item_wrap
3030

31-
def to_xml(self) -> Optional[Any]:
31+
def to_xml(self) -> Any | None:
3232
"""
3333
Convert to xml using dicttoxml.dicttoxml and then pretty print it.
3434
"""

json2xml/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class StringReadError(Exception):
2525
pass
2626

2727

28-
def readfromjson(filename: str) -> Dict[str, str]:
28+
def readfromjson(filename: str) -> dict[str, str]:
2929
"""Reads a JSON file and returns a dictionary."""
3030
try:
3131
with open(filename, encoding="utf-8") as jsondata:
@@ -36,7 +36,7 @@ def readfromjson(filename: str) -> Dict[str, str]:
3636
raise JSONReadError("Invalid JSON File")
3737

3838

39-
def readfromurl(url: str, params: Optional[Dict[str, str]] = None) -> Dict[str, str]:
39+
def readfromurl(url: str, params: dict[str, str] | None = None) -> dict[str, str]:
4040
"""Loads JSON data from a URL and returns a dictionary."""
4141
http = urllib3.PoolManager()
4242
response = http.request("GET", url, fields=params)
@@ -45,7 +45,7 @@ def readfromurl(url: str, params: Optional[Dict[str, str]] = None) -> Dict[str,
4545
raise URLReadError("URL is not returning correct response")
4646

4747

48-
def readfromstring(jsondata: str) -> Dict[str, str]:
48+
def readfromstring(jsondata: str) -> dict[str, str]:
4949
"""Loads JSON data from a string and returns a dictionary."""
5050
if not isinstance(jsondata, str):
5151
raise StringReadError("Input is not a proper JSON string")

tests/test_json2xml.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,6 @@ def test_read_from_invalid_json2(self):
5050
readfromjson("examples/wrongjson.json")
5151
assert pytest_wrapped_e.type == JSONReadError
5252

53-
def test_read_from_url(self):
54-
data = readfromurl("https://api.publicapis.org/entries")
55-
assert isinstance(data, dict)
56-
57-
def test_read_from_wrong_url(self):
58-
with pytest.raises(URLReadError) as pytest_wrapped_e:
59-
readfromurl("https://api.publicapis.org/entriesi")
60-
assert pytest_wrapped_e.type == URLReadError
61-
6253
def test_read_from_jsonstring(self):
6354
data = readfromstring(
6455
'{"login":"mojombo","id":1,"avatar_url":"https://avatars0.githubusercontent.com/u/1?v=4"}'

0 commit comments

Comments
 (0)