Skip to content
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
8 changes: 2 additions & 6 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, pypy3]
python-version: [3.6, 3.7, 3.8, 3.9, pypy3, '3.10.0-rc.1']
os: [
ubuntu-20.04,
ubuntu-18.04,
ubuntu-16.04,
macOS-latest,
windows-latest,
]
Expand All @@ -34,9 +32,7 @@ jobs:
pip install flake8
pip install xmltodict==0.12.0
# stop the build if there are Python syntax errors or undefined names
flake8 json2xml/
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
flake8 json2xml/ --exit-zero
- name: Test with pytest
run: |
python setup.py test
3 changes: 2 additions & 1 deletion json2xml/json2xml.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from typing import Optional, Any
from xml.dom.minidom import parseString
from json2xml import dicttoxml

Expand All @@ -17,7 +18,7 @@ def __init__(
self.attr_type = attr_type
self.root = root

def to_xml(self):
def to_xml(self) -> Optional[Any]:
"""
Convert to xml using dicttoxml.dicttoxml and then pretty print it.
"""
Expand Down
8 changes: 5 additions & 3 deletions json2xml/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Utils methods to convert XML data to dict from various sources"""
import json
from typing import Dict, Optional
import requests


Expand All @@ -15,7 +16,8 @@ class StringReadError(Exception):
pass


def readfromjson(filename: str) -> dict:

def readfromjson(filename: str) -> Dict[str, str]:
"""
Reads a json string and emits json string
"""
Expand All @@ -32,7 +34,7 @@ def readfromjson(filename: str) -> dict:
raise JSONReadError("Invalid JSON File")


def readfromurl(url: str, params: dict = None) -> dict:
def readfromurl(url: str, params: Optional[Dict[str, str]] = None) -> Dict[str, str]:
"""
Loads json from an URL over the internets
"""
Expand All @@ -45,7 +47,7 @@ def readfromurl(url: str, params: dict = None) -> dict:
raise URLReadError("URL is not returning correct response")


def readfromstring(jsondata: str) -> dict:
def readfromstring(jsondata: str) -> Dict[str, str]:
"""
Loads json from string
"""
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ disallow_untyped_defs = true
no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true
ignore_missing_imports = true
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
author="Vinit Kumar",
author_email="mail@vinitkumar.me",
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"Development Status :: 6 - Mature",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Natural Language :: English",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
],
description="Simple Python Library to convert JSON to XML",
install_requires=requirements,
Expand Down