Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-typepy for openSUSE:Factory checked in at 2021-11-04 16:09:07 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-typepy (Old) and /work/SRC/openSUSE:Factory/.python-typepy.new.1890 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-typepy" Thu Nov 4 16:09:07 2021 rev:7 rq:928318 version:1.3.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-typepy/python-typepy.changes 2021-05-01 00:46:59.083375556 +0200 +++ /work/SRC/openSUSE:Factory/.python-typepy.new.1890/python-typepy.changes 2021-11-04 16:09:08.417031789 +0100 @@ -1,0 +2,9 @@ +Sat Oct 30 20:46:13 UTC 2021 - Dirk M??ller <[email protected]> + +- update to 1.3.0: + * add python 3.6, drop support for python 3.5 + * Fix linting error + * Refactorings + * Add support for string with thousand separators as integer + +------------------------------------------------------------------- Old: ---- typepy-1.1.5.tar.gz New: ---- typepy-1.3.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-typepy.spec ++++++ --- /var/tmp/diff_new_pack.3eG2KZ/_old 2021-11-04 16:09:09.053032160 +0100 +++ /var/tmp/diff_new_pack.3eG2KZ/_new 2021-11-04 16:09:09.053032160 +0100 @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 Name: python-typepy -Version: 1.1.5 +Version: 1.3.0 Release: 0 Summary: Python library for run time variable type checker License: MIT ++++++ typepy-1.1.5.tar.gz -> typepy-1.3.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typepy-1.1.5/PKG-INFO new/typepy-1.3.0/PKG-INFO --- old/typepy-1.1.5/PKG-INFO 2021-04-11 14:44:49.806168000 +0200 +++ new/typepy-1.3.0/PKG-INFO 2021-09-20 16:50:14.700000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: typepy -Version: 1.1.5 +Version: 1.3.0 Summary: typepy is a Python library for variable type checker/validator/converter at a run time. Home-page: https://github.com/thombashi/typepy Author: Tsuyoshi Hombashi @@ -10,198 +10,6 @@ Project-URL: Source, https://github.com/thombashi/typepy Project-URL: Tracker, https://github.com/thombashi/typepy/issues Project-URL: Changes, https://github.com/thombashi/typepy/releases -Description: .. contents:: **typepy** - :backlinks: top - :depth: 2 - - Summary - ========= - `typepy <https://github.com/thombashi/typepy>`__ is a Python library for variable type checker/validator/converter at a run time. - - .. image:: https://badge.fury.io/py/typepy.svg - :target: https://badge.fury.io/py/typepy - :alt: PyPI package version - - .. image:: https://anaconda.org/conda-forge/typepy/badges/version.svg - :target: https://anaconda.org/conda-forge/typepy - :alt: conda-forge package version - - .. image:: https://img.shields.io/pypi/pyversions/typepy.svg - :target: https://pypi.org/project/typepy - :alt: Supported Python versions - - .. image:: https://img.shields.io/pypi/implementation/typepy.svg - :target: https://pypi.org/project/typepy - :alt: Supported Python implementations - - .. image:: https://github.com/thombashi/typepy/workflows/Tests/badge.svg - :target: https://github.com/thombashi/typepy/actions?query=workflow%3ATests - :alt: Linux/macOS/Windows CI status - - .. image:: https://coveralls.io/repos/github/thombashi/typepy/badge.svg?branch=master - :target: https://coveralls.io/github/thombashi/typepy?branch=master - :alt: Test coverage - - Features - ========== - - checking a value type - - validate a value for a type - - convert a value from a type to the other type - - The correspondence between Python types and ``typepy`` classes are as follows: - - .. table:: Supported Types - - ================================================ ======================================================================================================= - Python Type typepy: Type Class - ================================================ ======================================================================================================= - ``bool`` `Bool <https://typepy.rtfd.io/en/latest/pages/reference/type.html#bool-type>`__ - ``datetime`` `DateTime <https://typepy.rtfd.io/en/latest/pages/reference/type.html#datetime-type>`__ - ``dict`` `Dictionary <https://typepy.rtfd.io/en/latest/pages/reference/type.html#dictionary-type>`__ - ``float``/``decimal.Decimal`` (not infinity/NaN) `RealNumber <https://typepy.rtfd.io/en/latest/pages/reference/type.html#real-number-type>`__ - ``float``/``decimal.Decimal`` (infinity) `Infinity <https://typepy.rtfd.io/en/latest/pages/reference/type.html#infinity-type>`__ - ``float``/``decimal.Decimal`` (NaN) `Nan <https://typepy.rtfd.io/en/latest/pages/reference/type.html#nan-type>`__ - ``int`` `Integer <https://typepy.rtfd.io/en/latest/pages/reference/type.html#integer-type>`__ - ``list`` `List <https://typepy.rtfd.io/en/latest/pages/reference/type.html#list-type>`__ - ``None`` `None <https://typepy.rtfd.io/en/latest/pages/reference/type.html#none-type>`__ - ``str`` (not null) `String <https://typepy.rtfd.io/en/latest/pages/reference/type.html#string-type>`__ - ``str`` (null) `NullString <https://typepy.rtfd.io/en/latest/pages/reference/type.html#null-string-type>`__ - ``str`` (IP address) `IpAddress <https://typepy.rtfd.io/en/latest/pages/reference/type.html#ip-address-type>`__ - ================================================ ======================================================================================================= - - Installation - ============ - - Installation: pip - ------------------------------ - :: - - pip install typepy - - Install additional dependency packages with the following command if using ``typepy.DateTime`` class - - :: - - pip install typepy[datetime] - - Installation: conda - ------------------------------ - :: - - conda install -c conda-forge typepy - - Installation: apt - ------------------------------ - :: - - sudo add-apt-repository ppa:thombashi/ppa - sudo apt update - sudo apt install python3-typepy - - - Dependencies - ============ - - Python 3.5+ - - `Python package dependencies (automatically installed) <https://github.com/thombashi/typepy/network/dependencies>`__ - - Optioal dependencies - ---------------------------------- - These packages can be installed via ``pip install typepy[datetime]``: - - - `python-dateutil <https://dateutil.readthedocs.io/en/stable/>`__ - - `pytz <https://pypi.org/project/pytz/>`__ - - Usage - ======= - Type Check Method - ---------------------- - :Examples: - .. code-block:: pycon - - >>> from typepy import Integer - >>> Integer(1).is_type() - True - >>> Integer(1.1).is_type() - False - - - Type Validation Method - -------------------------------------------- - :Examples: - .. code-block:: pycon - - >>> from typepy import Integer - >>> Integer(1).validate() - >>> try: - ... Integer(1.1).validate() - ... except TypeError as e: - ... # validate() raised TypeError when the value unmatched the type class - ... print(e) - ... - invalid value type: expected=INTEGER, actual=<type 'float'> - - - Type Conversion Methods - -------------------------------------------- - - convert method - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - :Examples: - .. code-block:: pycon - - >>> from typepy import Integer, TypeConversionError - >>> Integer("1").convert() - 1 - >>> try: - ... Integer(1.1).convert() - ... except TypeConversionError as e: - ... # convert() raised TypeConversionError when conversion failed - ... print(e) - ... - failed to convert from float to INTEGER - - try_convert method - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - :Examples: - .. code-block:: pycon - - >>> from typepy import Integer - >>> Integer("1").try_convert() - 1 - >>> print(Integer(1.1).try_convert()) # try_convert() returned None when conversion failed - None - - force_convert - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - :Examples: - .. code-block:: pycon - - >>> from typepy import Integer, TypeConversionError - >>> Integer("1").force_convert() # force_convert() forcibly convert the value - 1 - >>> Integer(1.1).force_convert() - 1 - >>> try: - ... Integer("abc").force_convert() - ... except TypeConversionError as e: - ... # force_convert() raised TypeConversionError when the value not convertible - ... print(e) - ... - failed to force_convert to int: type=<class 'str'> - - - For more information - -------------------------------------------- - Type check/validate/convert results differed according to - ``strict_level`` value which can pass to typepy classes constructors as an argument. - More information can be found in the - `API reference <https://typepy.rtfd.io/en/latest/pages/reference/index.html>`__. - - Documentation - =============== - https://typepy.rtfd.io/ - - Keywords: library,type-checking,type-conversion,validator Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable @@ -210,7 +18,6 @@ Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 @@ -221,7 +28,206 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: Software Development :: Libraries Classifier: Topic :: Software Development :: Libraries :: Python Modules -Requires-Python: >=3.5 +Requires-Python: >=3.6 Description-Content-Type: text/x-rst Provides-Extra: datetime Provides-Extra: test +License-File: LICENSE + +.. contents:: **typepy** + :backlinks: top + :depth: 2 + +Summary +========= +`typepy <https://github.com/thombashi/typepy>`__ is a Python library for variable type checker/validator/converter at a run time. + +.. image:: https://badge.fury.io/py/typepy.svg + :target: https://badge.fury.io/py/typepy + :alt: PyPI package version + +.. image:: https://anaconda.org/conda-forge/typepy/badges/version.svg + :target: https://anaconda.org/conda-forge/typepy + :alt: conda-forge package version + +.. image:: https://img.shields.io/pypi/pyversions/typepy.svg + :target: https://pypi.org/project/typepy + :alt: Supported Python versions + +.. image:: https://img.shields.io/pypi/implementation/typepy.svg + :target: https://pypi.org/project/typepy + :alt: Supported Python implementations + +.. image:: https://github.com/thombashi/typepy/workflows/Tests/badge.svg + :target: https://github.com/thombashi/typepy/actions?query=workflow%3ATests + :alt: Linux/macOS/Windows CI status + +.. image:: https://coveralls.io/repos/github/thombashi/typepy/badge.svg?branch=master + :target: https://coveralls.io/github/thombashi/typepy?branch=master + :alt: Test coverage + +.. image:: https://github.com/thombashi/typepy/actions/workflows/codeql-analysis.yml/badge.svg + :target: https://github.com/thombashi/typepy/actions/workflows/codeql-analysis.yml + :alt: CodeQL + +Features +========== +- checking a value type +- validate a value for a type +- convert a value from a type to the other type + +The correspondence between Python types and ``typepy`` classes are as follows: + +.. table:: Supported Types + + ================================================ ======================================================================================================= + Python Type typepy: Type Class + ================================================ ======================================================================================================= + ``bool`` `Bool <https://typepy.rtfd.io/en/latest/pages/reference/type.html#bool-type>`__ + ``datetime`` `DateTime <https://typepy.rtfd.io/en/latest/pages/reference/type.html#datetime-type>`__ + ``dict`` `Dictionary <https://typepy.rtfd.io/en/latest/pages/reference/type.html#dictionary-type>`__ + ``float``/``decimal.Decimal`` (not infinity/NaN) `RealNumber <https://typepy.rtfd.io/en/latest/pages/reference/type.html#real-number-type>`__ + ``float``/``decimal.Decimal`` (infinity) `Infinity <https://typepy.rtfd.io/en/latest/pages/reference/type.html#infinity-type>`__ + ``float``/``decimal.Decimal`` (NaN) `Nan <https://typepy.rtfd.io/en/latest/pages/reference/type.html#nan-type>`__ + ``int`` `Integer <https://typepy.rtfd.io/en/latest/pages/reference/type.html#integer-type>`__ + ``list`` `List <https://typepy.rtfd.io/en/latest/pages/reference/type.html#list-type>`__ + ``None`` `None <https://typepy.rtfd.io/en/latest/pages/reference/type.html#none-type>`__ + ``str`` (not null) `String <https://typepy.rtfd.io/en/latest/pages/reference/type.html#string-type>`__ + ``str`` (null) `NullString <https://typepy.rtfd.io/en/latest/pages/reference/type.html#null-string-type>`__ + ``str`` (IP address) `IpAddress <https://typepy.rtfd.io/en/latest/pages/reference/type.html#ip-address-type>`__ + ================================================ ======================================================================================================= + +Installation +============ + +Installation: pip +------------------------------ +:: + + pip install typepy + +Install additional dependency packages with the following command if using ``typepy.DateTime`` class + +:: + + pip install typepy[datetime] + +Installation: conda +------------------------------ +:: + + conda install -c conda-forge typepy + +Installation: apt +------------------------------ +:: + + sudo add-apt-repository ppa:thombashi/ppa + sudo apt update + sudo apt install python3-typepy + + +Dependencies +============ +- Python 3.6+ +- `Python package dependencies (automatically installed) <https://github.com/thombashi/typepy/network/dependencies>`__ + +Optioal dependencies +---------------------------------- +These packages can be installed via ``pip install typepy[datetime]``: + +- `python-dateutil <https://dateutil.readthedocs.io/en/stable/>`__ +- `pytz <https://pypi.org/project/pytz/>`__ + +Usage +======= +Type Check Method +---------------------- +:Examples: + .. code-block:: pycon + + >>> from typepy import Integer + >>> Integer(1).is_type() + True + >>> Integer(1.1).is_type() + False + + +Type Validation Method +-------------------------------------------- +:Examples: + .. code-block:: pycon + + >>> from typepy import Integer + >>> Integer(1).validate() + >>> try: + ... Integer(1.1).validate() + ... except TypeError as e: + ... # validate() raised TypeError when the value unmatched the type class + ... print(e) + ... + invalid value type: expected=INTEGER, actual=<type 'float'> + + +Type Conversion Methods +-------------------------------------------- + +convert method +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +:Examples: + .. code-block:: pycon + + >>> from typepy import Integer, TypeConversionError + >>> Integer("1").convert() + 1 + >>> try: + ... Integer(1.1).convert() + ... except TypeConversionError as e: + ... # convert() raised TypeConversionError when conversion failed + ... print(e) + ... + failed to convert from float to INTEGER + +try_convert method +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +:Examples: + .. code-block:: pycon + + >>> from typepy import Integer + >>> Integer("1").try_convert() + 1 + >>> print(Integer(1.1).try_convert()) # try_convert() returned None when conversion failed + None + +force_convert +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +:Examples: + .. code-block:: pycon + + >>> from typepy import Integer, TypeConversionError + >>> Integer("1").force_convert() # force_convert() forcibly convert the value + 1 + >>> Integer(1.1).force_convert() + 1 + >>> try: + ... Integer("abc").force_convert() + ... except TypeConversionError as e: + ... # force_convert() raised TypeConversionError when the value not convertible + ... print(e) + ... + failed to force_convert to int: type=<class 'str'> + + +For more information +-------------------------------------------- +Type check/validate/convert results differed according to +``strict_level`` value which can pass to typepy classes constructors as an argument. +More information can be found in the +`API reference <https://typepy.rtfd.io/en/latest/pages/reference/index.html>`__. + +Documentation +=============== +https://typepy.rtfd.io/ + + + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typepy-1.1.5/README.rst new/typepy-1.3.0/README.rst --- old/typepy-1.1.5/README.rst 2021-04-11 14:44:33.000000000 +0200 +++ new/typepy-1.3.0/README.rst 2021-09-20 16:49:59.000000000 +0200 @@ -30,6 +30,10 @@ :target: https://coveralls.io/github/thombashi/typepy?branch=master :alt: Test coverage +.. image:: https://github.com/thombashi/typepy/actions/workflows/codeql-analysis.yml/badge.svg + :target: https://github.com/thombashi/typepy/actions/workflows/codeql-analysis.yml + :alt: CodeQL + Features ========== - checking a value type @@ -89,7 +93,7 @@ Dependencies ============ -- Python 3.5+ +- Python 3.6+ - `Python package dependencies (automatically installed) <https://github.com/thombashi/typepy/network/dependencies>`__ Optioal dependencies diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typepy-1.1.5/pyproject.toml new/typepy-1.3.0/pyproject.toml --- old/typepy-1.1.5/pyproject.toml 2021-04-11 14:44:33.000000000 +0200 +++ new/typepy-1.3.0/pyproject.toml 2021-09-20 16:49:59.000000000 +0200 @@ -56,3 +56,13 @@ 'abstractclassmethod', 'warnings.warn', ] + +[tool.mypy] +ignore_missing_imports = true +python_version = 3.6 + +pretty = true +show_error_codes = true +show_error_context = true +warn_unreachable = true +warn_unused_configs = true diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typepy-1.1.5/setup.py new/typepy-1.3.0/setup.py --- old/typepy-1.1.5/setup.py 2021-04-11 14:44:33.000000000 +0200 +++ new/typepy-1.3.0/setup.py 2021-09-20 16:49:59.000000000 +0200 @@ -9,11 +9,11 @@ MODULE_NAME = "typepy" -REPOSITORY_URL = "https://github.com/thombashi/{:s}".format(MODULE_NAME) +REPOSITORY_URL = f"https://github.com/thombashi/{MODULE_NAME:s}" REQUIREMENT_DIR = "requirements" ENCODING = "utf8" -pkg_info = {} # type: Dict[str, str] +pkg_info: Dict[str, str] = {} def get_release_command_class() -> Dict[str, setuptools.Command]: @@ -62,12 +62,12 @@ packages=setuptools.find_packages(exclude=["test*"]), package_data={MODULE_NAME: ["py.typed"]}, project_urls={ - "Documentation": "https://{:s}.rtfd.io/".format(MODULE_NAME), + "Documentation": f"https://{MODULE_NAME:s}.rtfd.io/", "Source": REPOSITORY_URL, - "Tracker": "{:s}/issues".format(REPOSITORY_URL), - "Changes": "{:s}/releases".format(REPOSITORY_URL), + "Tracker": f"{REPOSITORY_URL:s}/issues", + "Changes": f"{REPOSITORY_URL:s}/releases", }, - python_requires=">=3.5", + python_requires=">=3.6", install_requires=install_requires, extras_require={"datetime": DATETIME_REQUIRES, "test": tests_requires + DATETIME_REQUIRES}, classifiers=[ @@ -77,7 +77,6 @@ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typepy-1.1.5/test/checker/test_checker_bytes.py new/typepy-1.3.0/test/checker/test_checker_bytes.py --- old/typepy-1.1.5/test/checker/test_checker_bytes.py 2021-04-11 14:44:33.000000000 +0200 +++ new/typepy-1.3.0/test/checker/test_checker_bytes.py 2021-09-20 16:49:59.000000000 +0200 @@ -19,9 +19,7 @@ ["value", "strict_level", "expected"], list(itertools.product([], [StrictLevel.MIN, StrictLevel.MAX], [False])) + list( - itertools.product( - [b"abc", "?????????".encode("utf8")], [StrictLevel.MIN, StrictLevel.MAX], [True] - ) + itertools.product([b"abc", "?????????".encode()], [StrictLevel.MIN, StrictLevel.MAX], [True]) ) + list(itertools.product([b" ", b"\n"], [StrictLevel.MIN], [True])) + list( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typepy-1.1.5/test/checker/test_checker_dictionary.py new/typepy-1.3.0/test/checker/test_checker_dictionary.py --- old/typepy-1.1.5/test/checker/test_checker_dictionary.py 2021-04-11 14:44:33.000000000 +0200 +++ new/typepy-1.3.0/test/checker/test_checker_dictionary.py 2021-09-20 16:49:59.000000000 +0200 @@ -36,7 +36,7 @@ ] + list( itertools.product( - [1, "a", "???".encode("utf8"), nan, True, None], + [1, "a", "???".encode(), nan, True, None], [StrictLevel.MIN, StrictLevel.MAX], [False], ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typepy-1.1.5/test/converter/test_integer.py new/typepy-1.3.0/test/converter/test_integer.py --- old/typepy-1.1.5/test/converter/test_integer.py 2021-04-11 14:44:33.000000000 +0200 +++ new/typepy-1.3.0/test/converter/test_integer.py 2021-09-20 16:49:59.000000000 +0200 @@ -24,6 +24,7 @@ ["convert", 0, "1.0", 1], ["convert", 0, "1.1", 1], ["convert", 0, 9223372036854775807, 9223372036854775807], + ["convert", 0, "1,000,000,000,000", 1000000000000], ["convert", 0, True, 1], ["convert", 0, None, "E"], ["convert", 0, inf, "E"], @@ -37,6 +38,7 @@ ["convert", 1, "1.0", 1], ["convert", 1, "1.1", "E"], ["convert", 1, 9223372036854775807, 9223372036854775807], + ["convert", 1, "1,000,000,000,000", 1000000000000], ["convert", 1, True, "E"], ["convert", 1, None, "E"], ["convert", 1, inf, "E"], @@ -50,6 +52,7 @@ ["convert", 2, "1.0", "E"], ["convert", 2, "1.1", "E"], ["convert", 2, 9223372036854775807, 9223372036854775807], + ["convert", 2, "1,000,000,000,000", "E"], ["convert", 2, True, "E"], ["convert", 2, None, "E"], ["convert", 2, inf, "E"], @@ -63,6 +66,7 @@ ["try_convert", 0, "1.0", 1], ["try_convert", 0, "1.1", 1], ["try_convert", 0, 9223372036854775807, 9223372036854775807], + ["try_convert", 0, "1,000,000,000,000", 1000000000000], ["try_convert", 0, True, 1], ["try_convert", 0, None, None], ["try_convert", 0, inf, None], @@ -76,6 +80,7 @@ ["try_convert", 1, "1.0", 1], ["try_convert", 1, "1.1", None], ["try_convert", 1, 9223372036854775807, 9223372036854775807], + ["try_convert", 1, "1,000,000,000,000", 1000000000000], ["try_convert", 1, True, None], ["try_convert", 1, None, None], ["try_convert", 1, inf, None], @@ -89,6 +94,7 @@ ["try_convert", 2, "1.0", None], ["try_convert", 2, "1.1", None], ["try_convert", 2, 9223372036854775807, 9223372036854775807], + ["try_convert", 2, "1,000,000,000,000", None], ["try_convert", 2, True, None], ["try_convert", 2, None, None], ["try_convert", 2, inf, None], @@ -102,6 +108,7 @@ ["force_convert", 0, "1.0", 1], ["force_convert", 0, "1.1", 1], ["force_convert", 0, 9223372036854775807, 9223372036854775807], + ["force_convert", 0, "1,000,000,000,000", 1000000000000], ["force_convert", 0, True, 1], ["force_convert", 0, None, "E"], ["force_convert", 0, inf, "E"], @@ -115,6 +122,7 @@ ["force_convert", 1, "1.0", 1], ["force_convert", 1, "1.1", 1], ["force_convert", 1, 9223372036854775807, 9223372036854775807], + ["force_convert", 1, "1,000,000,000,000", 1000000000000], ["force_convert", 1, True, 1], ["force_convert", 1, None, "E"], ["force_convert", 1, inf, "E"], @@ -128,6 +136,7 @@ ["force_convert", 2, "1.0", 1], ["force_convert", 2, "1.1", 1], ["force_convert", 2, 9223372036854775807, 9223372036854775807], + ["force_convert", 2, "1,000,000,000,000", 1000000000000], ["force_convert", 2, True, 1], ["force_convert", 2, None, "E"], ["force_convert", 2, inf, "E"], diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typepy-1.1.5/test/test_common.py new/typepy-1.3.0/test/test_common.py --- old/typepy-1.1.5/test/test_common.py 1970-01-01 01:00:00.000000000 +0100 +++ new/typepy-1.3.0/test/test_common.py 2021-09-20 16:49:59.000000000 +0200 @@ -0,0 +1,20 @@ +import pytest + +from typepy._common import remove_thousand_sep + + +class Test_remove_thousand_sep: + @pytest.mark.parametrize( + ["value", "expected"], + [ + ["1,000,000,000,000", "1000000000000"], + ["100,000,000,000", "100000000000"], + ["10,000,000,000", "10000000000"], + ["9,999,999,999", "9999999999"], + ["123,456,789", "123456789"], + ["2021-01-23", "2021-01-23"], + ["1,000.1", "1000.1"], + ], + ) + def test_normal(self, value, expected): + assert remove_thousand_sep(value) == expected diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typepy-1.1.5/tox.ini new/typepy-1.3.0/tox.ini --- old/typepy-1.1.5/tox.ini 2021-04-11 14:44:33.000000000 +0200 +++ new/typepy-1.3.0/tox.ini 2021-09-20 16:49:59.000000000 +0200 @@ -1,6 +1,6 @@ [tox] envlist = - py{35,36,37,38,39,310} + py{36,37,38,39,310} pypy3 build clean @@ -28,7 +28,7 @@ [testenv:clean] skip_install = true deps = - cleanpy + cleanpy>=0.3 commands = cleanpy --all --exclude-envs . @@ -36,9 +36,9 @@ deps = .[test] coverage[toml]>=5 - pytest-cov commands = - pytest --cov {posargs:-vv} + coverage run -m pytest {posargs:-vv} + coverage report -m [testenv:docs] basepython = python3.8 @@ -55,7 +55,7 @@ black isort>=5 commands = - black setup.py test typepy + black make_test_cases.py setup.py test typepy autoflake --in-place --recursive --remove-all-unused-imports --ignore-init-module-imports . isort . @@ -65,9 +65,13 @@ deps = codespell pylama + mypy>=0.902 + types-python-dateutil + types-pytz commands = python setup.py check codespell typepy docs/pages test -q2 --check-filenames + mypy typepy setup.py pylama [testenv:readme] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typepy-1.1.5/typepy/__version__.py new/typepy-1.3.0/typepy/__version__.py --- old/typepy-1.1.5/typepy/__version__.py 2021-04-11 14:44:33.000000000 +0200 +++ new/typepy-1.3.0/typepy/__version__.py 2021-09-20 16:49:59.000000000 +0200 @@ -1,6 +1,6 @@ __author__ = "Tsuyoshi Hombashi" -__copyright__ = "Copyright 2017, {}".format(__author__) +__copyright__ = f"Copyright 2017, {__author__}" __license__ = "MIT License" -__version__ = "1.1.5" +__version__ = "1.3.0" __maintainer__ = __author__ __email__ = "[email protected]" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typepy-1.1.5/typepy/_common.py new/typepy-1.3.0/typepy/_common.py --- old/typepy-1.1.5/typepy/_common.py 2021-04-11 14:44:33.000000000 +0200 +++ new/typepy-1.3.0/typepy/_common.py 2021-09-20 16:49:59.000000000 +0200 @@ -3,7 +3,15 @@ ansi_escape = re.compile(r"(\x9b|\x1b\[)[0-?]*[ -\/]*[@-~]", re.IGNORECASE) +REGEXP_THOUSAND_SEP = re.compile(r"\d{1,3}(,\d{1,3})+") def strip_ansi_escape(value: Any) -> str: return ansi_escape.sub("", value) + + +def remove_thousand_sep(value: str) -> str: + if REGEXP_THOUSAND_SEP.search(value) is None: + return value + + return value.replace(",", "") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typepy-1.1.5/typepy/checker/_checker.py new/typepy-1.3.0/typepy/checker/_checker.py --- old/typepy-1.1.5/typepy/checker/_checker.py 2021-04-11 14:44:33.000000000 +0200 +++ new/typepy-1.3.0/typepy/checker/_checker.py 2021-09-20 16:49:59.000000000 +0200 @@ -34,7 +34,7 @@ if strict_level > self.max_strict_level: return self.__checker_mapping[self.max_strict_level] - raise ValueError("unexpected strict level: {}".format(strict_level)) + raise ValueError(f"unexpected strict level: {strict_level}") class TypeCheckerBase(TypeCheckerInterface): @@ -59,7 +59,7 @@ if self.is_type(): return - raise TypeError("invalid value type: actual={}".format(type(self._value))) + raise TypeError(f"invalid value type: actual={type(self._value)}") def is_exclude_instance(self): return False diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typepy-1.1.5/typepy/converter/_bool.py new/typepy-1.3.0/typepy/converter/_bool.py --- old/typepy-1.1.5/typepy/converter/_bool.py 2021-04-11 14:44:33.000000000 +0200 +++ new/typepy-1.3.0/typepy/converter/_bool.py 2021-09-20 16:49:59.000000000 +0200 @@ -24,9 +24,7 @@ except (TypeError, ValueError): pass - raise TypeConversionError( - "failed to force_convert to bool: type={}".format(type(self._value)) - ) + raise TypeConversionError(f"failed to force_convert to bool: type={type(self._value)}") @staticmethod def __strict_strtobool(value): @@ -36,11 +34,11 @@ try: lower_text = value.casefold() except AttributeError: - raise ValueError("invalid value '{}'".format(str(value))) + raise ValueError(f"invalid value '{str(value)}'") if lower_text in ["true"]: return True elif lower_text in ["false"]: return False - raise ValueError("invalid value '{}'".format(str(value))) + raise ValueError(f"invalid value '{str(value)}'") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typepy-1.1.5/typepy/converter/_datetime.py new/typepy-1.3.0/typepy/converter/_datetime.py --- old/typepy-1.1.5/typepy/converter/_datetime.py 2021-04-11 14:44:33.000000000 +0200 +++ new/typepy-1.3.0/typepy/converter/_datetime.py 2021-09-20 16:49:59.000000000 +0200 @@ -106,9 +106,7 @@ pass if self.__datetime is None: - raise TypeConversionError( - "failed to parse as a datetime: type={}".format(type(self._value)) - ) + raise TypeConversionError(f"failed to parse as a datetime: type={type(self._value)}") if self.__timezone: pytz_timezone = self.__timezone @@ -150,9 +148,9 @@ try: Version(self._value) raise TypeConversionError( - "invalid datetime string: version string found {}".format(self._value) + f"invalid datetime string: version string found {self._value}" ) except InvalidVersion: pass except TypeError: - raise TypeConversionError("invalid datetime string: type={}".format(type(self._value))) + raise TypeConversionError(f"invalid datetime string: type={type(self._value)}") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typepy-1.1.5/typepy/converter/_dictionary.py new/typepy-1.3.0/typepy/converter/_dictionary.py --- old/typepy-1.1.5/typepy/converter/_dictionary.py 2021-04-11 14:44:33.000000000 +0200 +++ new/typepy-1.3.0/typepy/converter/_dictionary.py 2021-09-20 16:49:59.000000000 +0200 @@ -22,5 +22,5 @@ pass raise TypeConversionError( - "failed to force_convert to dictionary: type={}".format(type(self._value)) + f"failed to force_convert to dictionary: type={type(self._value)}" ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typepy-1.1.5/typepy/converter/_integer.py new/typepy-1.3.0/typepy/converter/_integer.py --- old/typepy-1.1.5/typepy/converter/_integer.py 2021-04-11 14:44:33.000000000 +0200 +++ new/typepy-1.3.0/typepy/converter/_integer.py 2021-09-20 16:49:59.000000000 +0200 @@ -4,7 +4,7 @@ from decimal import Decimal, InvalidOperation -from .._common import strip_ansi_escape +from .._common import remove_thousand_sep, strip_ansi_escape from .._const import DefaultValue, ParamKey from ..error import TypeConversionError from ._interface import AbstractValueConverter @@ -13,16 +13,19 @@ class IntegerConverter(AbstractValueConverter): def force_convert(self): try: - return int(Decimal(self._value)) + value = remove_thousand_sep(self._value) + except TypeError: + value = self._value + + try: + return int(Decimal(value)) except (TypeError, OverflowError, ValueError, InvalidOperation): pass if self._params.get(ParamKey.STRIP_ANSI_ESCAPE, DefaultValue.STRIP_ANSI_ESCAPE): try: - return int(Decimal(strip_ansi_escape(self._value))) + return int(Decimal(strip_ansi_escape(value))) except (TypeError, OverflowError, ValueError, InvalidOperation): pass - raise TypeConversionError( - "failed to force_convert to int: type={}".format(type(self._value)) - ) + raise TypeConversionError(f"failed to force_convert to int: type={type(value)}") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typepy-1.1.5/typepy/converter/_ipaddress.py new/typepy-1.3.0/typepy/converter/_ipaddress.py --- old/typepy-1.1.5/typepy/converter/_ipaddress.py 2021-04-11 14:44:33.000000000 +0200 +++ new/typepy-1.3.0/typepy/converter/_ipaddress.py 2021-09-20 16:49:59.000000000 +0200 @@ -26,5 +26,5 @@ pass raise TypeConversionError( - "failed to force_convert to dictionary: type={}".format(type(self._value)) + f"failed to force_convert to dictionary: type={type(self._value)}" ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typepy-1.1.5/typepy/converter/_list.py new/typepy-1.3.0/typepy/converter/_list.py --- old/typepy-1.1.5/typepy/converter/_list.py 2021-04-11 14:44:33.000000000 +0200 +++ new/typepy-1.3.0/typepy/converter/_list.py 2021-09-20 16:49:59.000000000 +0200 @@ -11,6 +11,4 @@ try: return list(self._value) except (TypeError, ValueError): - raise TypeConversionError( - "failed to force_convert to list: type={}".format(type(self._value)) - ) + raise TypeConversionError(f"failed to force_convert to list: type={type(self._value)}") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typepy-1.1.5/typepy/converter/_realnumber.py new/typepy-1.3.0/typepy/converter/_realnumber.py --- old/typepy-1.1.5/typepy/converter/_realnumber.py 2021-04-11 14:44:33.000000000 +0200 +++ new/typepy-1.3.0/typepy/converter/_realnumber.py 2021-09-20 16:49:59.000000000 +0200 @@ -36,6 +36,4 @@ except (TypeError, ValueError, decimal.InvalidOperation): pass - raise TypeConversionError( - "failed to force_convert to float: type={}".format(type(self._value)) - ) + raise TypeConversionError(f"failed to force_convert to float: type={type(self._value)}") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typepy-1.1.5/typepy/type/_base.py new/typepy-1.3.0/typepy/type/_base.py --- old/typepy-1.1.5/typepy/type/_base.py 2021-04-11 14:44:33.000000000 +0200 +++ new/typepy-1.3.0/typepy/type/_base.py 2021-09-20 16:49:59.000000000 +0200 @@ -45,16 +45,16 @@ self.__checker = self._create_type_checker() self.__converter = self._create_type_converter() - self.__is_type_result = None # type: Optional[bool] + self.__is_type_result: Optional[bool] = None def __repr__(self) -> str: return ", ".join( [ - "value={}".format(self._data), - "typename={}".format(self.typename), - "strict_level={}".format(self._strict_level), - "is_type={}".format(self.is_type()), - "try_convert={}".format(self.try_convert()), + f"value={self._data}", + f"typename={self.typename}", + f"strict_level={self._strict_level}", + f"is_type={self.is_type()}", + f"try_convert={self.try_convert()}", ] ) @@ -100,9 +100,7 @@ if not error_message: error_message = "invalid value type" - raise TypeError( - "{}: expected={}, actual={}".format(error_message, self.typename, type(self._data)) - ) + raise TypeError(f"{error_message}: expected={self.typename}, actual={type(self._data)}") def convert(self): """ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typepy-1.1.5/typepy.egg-info/PKG-INFO new/typepy-1.3.0/typepy.egg-info/PKG-INFO --- old/typepy-1.1.5/typepy.egg-info/PKG-INFO 2021-04-11 14:44:49.000000000 +0200 +++ new/typepy-1.3.0/typepy.egg-info/PKG-INFO 2021-09-20 16:50:14.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: typepy -Version: 1.1.5 +Version: 1.3.0 Summary: typepy is a Python library for variable type checker/validator/converter at a run time. Home-page: https://github.com/thombashi/typepy Author: Tsuyoshi Hombashi @@ -10,198 +10,6 @@ Project-URL: Source, https://github.com/thombashi/typepy Project-URL: Tracker, https://github.com/thombashi/typepy/issues Project-URL: Changes, https://github.com/thombashi/typepy/releases -Description: .. contents:: **typepy** - :backlinks: top - :depth: 2 - - Summary - ========= - `typepy <https://github.com/thombashi/typepy>`__ is a Python library for variable type checker/validator/converter at a run time. - - .. image:: https://badge.fury.io/py/typepy.svg - :target: https://badge.fury.io/py/typepy - :alt: PyPI package version - - .. image:: https://anaconda.org/conda-forge/typepy/badges/version.svg - :target: https://anaconda.org/conda-forge/typepy - :alt: conda-forge package version - - .. image:: https://img.shields.io/pypi/pyversions/typepy.svg - :target: https://pypi.org/project/typepy - :alt: Supported Python versions - - .. image:: https://img.shields.io/pypi/implementation/typepy.svg - :target: https://pypi.org/project/typepy - :alt: Supported Python implementations - - .. image:: https://github.com/thombashi/typepy/workflows/Tests/badge.svg - :target: https://github.com/thombashi/typepy/actions?query=workflow%3ATests - :alt: Linux/macOS/Windows CI status - - .. image:: https://coveralls.io/repos/github/thombashi/typepy/badge.svg?branch=master - :target: https://coveralls.io/github/thombashi/typepy?branch=master - :alt: Test coverage - - Features - ========== - - checking a value type - - validate a value for a type - - convert a value from a type to the other type - - The correspondence between Python types and ``typepy`` classes are as follows: - - .. table:: Supported Types - - ================================================ ======================================================================================================= - Python Type typepy: Type Class - ================================================ ======================================================================================================= - ``bool`` `Bool <https://typepy.rtfd.io/en/latest/pages/reference/type.html#bool-type>`__ - ``datetime`` `DateTime <https://typepy.rtfd.io/en/latest/pages/reference/type.html#datetime-type>`__ - ``dict`` `Dictionary <https://typepy.rtfd.io/en/latest/pages/reference/type.html#dictionary-type>`__ - ``float``/``decimal.Decimal`` (not infinity/NaN) `RealNumber <https://typepy.rtfd.io/en/latest/pages/reference/type.html#real-number-type>`__ - ``float``/``decimal.Decimal`` (infinity) `Infinity <https://typepy.rtfd.io/en/latest/pages/reference/type.html#infinity-type>`__ - ``float``/``decimal.Decimal`` (NaN) `Nan <https://typepy.rtfd.io/en/latest/pages/reference/type.html#nan-type>`__ - ``int`` `Integer <https://typepy.rtfd.io/en/latest/pages/reference/type.html#integer-type>`__ - ``list`` `List <https://typepy.rtfd.io/en/latest/pages/reference/type.html#list-type>`__ - ``None`` `None <https://typepy.rtfd.io/en/latest/pages/reference/type.html#none-type>`__ - ``str`` (not null) `String <https://typepy.rtfd.io/en/latest/pages/reference/type.html#string-type>`__ - ``str`` (null) `NullString <https://typepy.rtfd.io/en/latest/pages/reference/type.html#null-string-type>`__ - ``str`` (IP address) `IpAddress <https://typepy.rtfd.io/en/latest/pages/reference/type.html#ip-address-type>`__ - ================================================ ======================================================================================================= - - Installation - ============ - - Installation: pip - ------------------------------ - :: - - pip install typepy - - Install additional dependency packages with the following command if using ``typepy.DateTime`` class - - :: - - pip install typepy[datetime] - - Installation: conda - ------------------------------ - :: - - conda install -c conda-forge typepy - - Installation: apt - ------------------------------ - :: - - sudo add-apt-repository ppa:thombashi/ppa - sudo apt update - sudo apt install python3-typepy - - - Dependencies - ============ - - Python 3.5+ - - `Python package dependencies (automatically installed) <https://github.com/thombashi/typepy/network/dependencies>`__ - - Optioal dependencies - ---------------------------------- - These packages can be installed via ``pip install typepy[datetime]``: - - - `python-dateutil <https://dateutil.readthedocs.io/en/stable/>`__ - - `pytz <https://pypi.org/project/pytz/>`__ - - Usage - ======= - Type Check Method - ---------------------- - :Examples: - .. code-block:: pycon - - >>> from typepy import Integer - >>> Integer(1).is_type() - True - >>> Integer(1.1).is_type() - False - - - Type Validation Method - -------------------------------------------- - :Examples: - .. code-block:: pycon - - >>> from typepy import Integer - >>> Integer(1).validate() - >>> try: - ... Integer(1.1).validate() - ... except TypeError as e: - ... # validate() raised TypeError when the value unmatched the type class - ... print(e) - ... - invalid value type: expected=INTEGER, actual=<type 'float'> - - - Type Conversion Methods - -------------------------------------------- - - convert method - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - :Examples: - .. code-block:: pycon - - >>> from typepy import Integer, TypeConversionError - >>> Integer("1").convert() - 1 - >>> try: - ... Integer(1.1).convert() - ... except TypeConversionError as e: - ... # convert() raised TypeConversionError when conversion failed - ... print(e) - ... - failed to convert from float to INTEGER - - try_convert method - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - :Examples: - .. code-block:: pycon - - >>> from typepy import Integer - >>> Integer("1").try_convert() - 1 - >>> print(Integer(1.1).try_convert()) # try_convert() returned None when conversion failed - None - - force_convert - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - :Examples: - .. code-block:: pycon - - >>> from typepy import Integer, TypeConversionError - >>> Integer("1").force_convert() # force_convert() forcibly convert the value - 1 - >>> Integer(1.1).force_convert() - 1 - >>> try: - ... Integer("abc").force_convert() - ... except TypeConversionError as e: - ... # force_convert() raised TypeConversionError when the value not convertible - ... print(e) - ... - failed to force_convert to int: type=<class 'str'> - - - For more information - -------------------------------------------- - Type check/validate/convert results differed according to - ``strict_level`` value which can pass to typepy classes constructors as an argument. - More information can be found in the - `API reference <https://typepy.rtfd.io/en/latest/pages/reference/index.html>`__. - - Documentation - =============== - https://typepy.rtfd.io/ - - Keywords: library,type-checking,type-conversion,validator Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable @@ -210,7 +18,6 @@ Classifier: License :: OSI Approved :: MIT License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 @@ -221,7 +28,206 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: Software Development :: Libraries Classifier: Topic :: Software Development :: Libraries :: Python Modules -Requires-Python: >=3.5 +Requires-Python: >=3.6 Description-Content-Type: text/x-rst Provides-Extra: datetime Provides-Extra: test +License-File: LICENSE + +.. contents:: **typepy** + :backlinks: top + :depth: 2 + +Summary +========= +`typepy <https://github.com/thombashi/typepy>`__ is a Python library for variable type checker/validator/converter at a run time. + +.. image:: https://badge.fury.io/py/typepy.svg + :target: https://badge.fury.io/py/typepy + :alt: PyPI package version + +.. image:: https://anaconda.org/conda-forge/typepy/badges/version.svg + :target: https://anaconda.org/conda-forge/typepy + :alt: conda-forge package version + +.. image:: https://img.shields.io/pypi/pyversions/typepy.svg + :target: https://pypi.org/project/typepy + :alt: Supported Python versions + +.. image:: https://img.shields.io/pypi/implementation/typepy.svg + :target: https://pypi.org/project/typepy + :alt: Supported Python implementations + +.. image:: https://github.com/thombashi/typepy/workflows/Tests/badge.svg + :target: https://github.com/thombashi/typepy/actions?query=workflow%3ATests + :alt: Linux/macOS/Windows CI status + +.. image:: https://coveralls.io/repos/github/thombashi/typepy/badge.svg?branch=master + :target: https://coveralls.io/github/thombashi/typepy?branch=master + :alt: Test coverage + +.. image:: https://github.com/thombashi/typepy/actions/workflows/codeql-analysis.yml/badge.svg + :target: https://github.com/thombashi/typepy/actions/workflows/codeql-analysis.yml + :alt: CodeQL + +Features +========== +- checking a value type +- validate a value for a type +- convert a value from a type to the other type + +The correspondence between Python types and ``typepy`` classes are as follows: + +.. table:: Supported Types + + ================================================ ======================================================================================================= + Python Type typepy: Type Class + ================================================ ======================================================================================================= + ``bool`` `Bool <https://typepy.rtfd.io/en/latest/pages/reference/type.html#bool-type>`__ + ``datetime`` `DateTime <https://typepy.rtfd.io/en/latest/pages/reference/type.html#datetime-type>`__ + ``dict`` `Dictionary <https://typepy.rtfd.io/en/latest/pages/reference/type.html#dictionary-type>`__ + ``float``/``decimal.Decimal`` (not infinity/NaN) `RealNumber <https://typepy.rtfd.io/en/latest/pages/reference/type.html#real-number-type>`__ + ``float``/``decimal.Decimal`` (infinity) `Infinity <https://typepy.rtfd.io/en/latest/pages/reference/type.html#infinity-type>`__ + ``float``/``decimal.Decimal`` (NaN) `Nan <https://typepy.rtfd.io/en/latest/pages/reference/type.html#nan-type>`__ + ``int`` `Integer <https://typepy.rtfd.io/en/latest/pages/reference/type.html#integer-type>`__ + ``list`` `List <https://typepy.rtfd.io/en/latest/pages/reference/type.html#list-type>`__ + ``None`` `None <https://typepy.rtfd.io/en/latest/pages/reference/type.html#none-type>`__ + ``str`` (not null) `String <https://typepy.rtfd.io/en/latest/pages/reference/type.html#string-type>`__ + ``str`` (null) `NullString <https://typepy.rtfd.io/en/latest/pages/reference/type.html#null-string-type>`__ + ``str`` (IP address) `IpAddress <https://typepy.rtfd.io/en/latest/pages/reference/type.html#ip-address-type>`__ + ================================================ ======================================================================================================= + +Installation +============ + +Installation: pip +------------------------------ +:: + + pip install typepy + +Install additional dependency packages with the following command if using ``typepy.DateTime`` class + +:: + + pip install typepy[datetime] + +Installation: conda +------------------------------ +:: + + conda install -c conda-forge typepy + +Installation: apt +------------------------------ +:: + + sudo add-apt-repository ppa:thombashi/ppa + sudo apt update + sudo apt install python3-typepy + + +Dependencies +============ +- Python 3.6+ +- `Python package dependencies (automatically installed) <https://github.com/thombashi/typepy/network/dependencies>`__ + +Optioal dependencies +---------------------------------- +These packages can be installed via ``pip install typepy[datetime]``: + +- `python-dateutil <https://dateutil.readthedocs.io/en/stable/>`__ +- `pytz <https://pypi.org/project/pytz/>`__ + +Usage +======= +Type Check Method +---------------------- +:Examples: + .. code-block:: pycon + + >>> from typepy import Integer + >>> Integer(1).is_type() + True + >>> Integer(1.1).is_type() + False + + +Type Validation Method +-------------------------------------------- +:Examples: + .. code-block:: pycon + + >>> from typepy import Integer + >>> Integer(1).validate() + >>> try: + ... Integer(1.1).validate() + ... except TypeError as e: + ... # validate() raised TypeError when the value unmatched the type class + ... print(e) + ... + invalid value type: expected=INTEGER, actual=<type 'float'> + + +Type Conversion Methods +-------------------------------------------- + +convert method +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +:Examples: + .. code-block:: pycon + + >>> from typepy import Integer, TypeConversionError + >>> Integer("1").convert() + 1 + >>> try: + ... Integer(1.1).convert() + ... except TypeConversionError as e: + ... # convert() raised TypeConversionError when conversion failed + ... print(e) + ... + failed to convert from float to INTEGER + +try_convert method +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +:Examples: + .. code-block:: pycon + + >>> from typepy import Integer + >>> Integer("1").try_convert() + 1 + >>> print(Integer(1.1).try_convert()) # try_convert() returned None when conversion failed + None + +force_convert +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +:Examples: + .. code-block:: pycon + + >>> from typepy import Integer, TypeConversionError + >>> Integer("1").force_convert() # force_convert() forcibly convert the value + 1 + >>> Integer(1.1).force_convert() + 1 + >>> try: + ... Integer("abc").force_convert() + ... except TypeConversionError as e: + ... # force_convert() raised TypeConversionError when the value not convertible + ... print(e) + ... + failed to force_convert to int: type=<class 'str'> + + +For more information +-------------------------------------------- +Type check/validate/convert results differed according to +``strict_level`` value which can pass to typepy classes constructors as an argument. +More information can be found in the +`API reference <https://typepy.rtfd.io/en/latest/pages/reference/index.html>`__. + +Documentation +=============== +https://typepy.rtfd.io/ + + + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/typepy-1.1.5/typepy.egg-info/SOURCES.txt new/typepy-1.3.0/typepy.egg-info/SOURCES.txt --- old/typepy-1.1.5/typepy.egg-info/SOURCES.txt 2021-04-11 14:44:49.000000000 +0200 +++ new/typepy-1.3.0/typepy.egg-info/SOURCES.txt 2021-09-20 16:50:14.000000000 +0200 @@ -9,6 +9,7 @@ requirements/requirements.txt requirements/test_requirements.txt test/__init__.py +test/test_common.py test/test_function.py test/test_str_function.py test/test_type.py
