diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index ebf86e7..b0395e1 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -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, ] @@ -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 diff --git a/json2xml/json2xml.py b/json2xml/json2xml.py index 3817d94..3809e83 100644 --- a/json2xml/json2xml.py +++ b/json2xml/json2xml.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +from typing import Optional, Any from xml.dom.minidom import parseString from json2xml import dicttoxml @@ -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. """ diff --git a/json2xml/utils.py b/json2xml/utils.py index f8fe893..ecb2ac9 100644 --- a/json2xml/utils.py +++ b/json2xml/utils.py @@ -1,5 +1,6 @@ """Utils methods to convert XML data to dict from various sources""" import json +from typing import Dict, Optional import requests @@ -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 """ @@ -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 """ @@ -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 """ diff --git a/setup.cfg b/setup.cfg index c6a46a6..8ffa5d3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -29,3 +29,4 @@ disallow_untyped_defs = true no_implicit_optional = true warn_redundant_casts = true warn_unused_ignores = true +ignore_missing_imports = true diff --git a/setup.py b/setup.py index f40a868..a1a3d94 100644 --- a/setup.py +++ b/setup.py @@ -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,