{"id":15672495,"url":"https://github.com/thombashi/typepy","last_synced_at":"2025-09-07T08:38:36.533Z","repository":{"id":54510700,"uuid":"81633755","full_name":"thombashi/typepy","owner":"thombashi","description":"A Python library for variable type checker/validator/converter at a run time.","archived":false,"fork":false,"pushed_at":"2025-06-23T18:12:12.000Z","size":426,"stargazers_count":16,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-20T04:09:55.226Z","etag":null,"topics":["python-library","type-checking","type-conversion","type-detection","validator"],"latest_commit_sha":null,"homepage":"https://typepy.rtfd.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thombashi.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-02-11T05:49:21.000Z","updated_at":"2024-12-29T09:15:46.000Z","dependencies_parsed_at":"2023-12-15T02:18:02.513Z","dependency_job_id":"4d9236b5-57c3-4c61-b93f-9542a993b782","html_url":"https://github.com/thombashi/typepy","commit_stats":{"total_commits":553,"total_committers":3,"mean_commits":"184.33333333333334","dds":"0.16636528028933095","last_synced_commit":"c9f282b92ed9bd3b4ee4c9411f9b440d6d1a2ca1"},"previous_names":["thombashi/pytypeutil"],"tags_count":63,"template":false,"template_full_name":null,"purl":"pkg:github/thombashi/typepy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thombashi%2Ftypepy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thombashi%2Ftypepy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thombashi%2Ftypepy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thombashi%2Ftypepy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thombashi","download_url":"https://codeload.github.com/thombashi/typepy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thombashi%2Ftypepy/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267652770,"owners_count":24122098,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python-library","type-checking","type-conversion","type-detection","validator"],"created_at":"2024-10-03T15:27:28.091Z","updated_at":"2025-07-29T08:09:21.556Z","avatar_url":"https://github.com/thombashi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":".. contents:: **typepy**\n   :backlinks: top\n   :depth: 2\n\nSummary\n=========\n`typepy \u003chttps://github.com/thombashi/typepy\u003e`__ is a Python library for variable type checker/validator/converter at a run time.\n\n.. image:: https://badge.fury.io/py/typepy.svg\n    :target: https://badge.fury.io/py/typepy\n    :alt: PyPI package version\n\n.. image:: https://anaconda.org/conda-forge/typepy/badges/version.svg\n    :target: https://anaconda.org/conda-forge/typepy\n    :alt: conda-forge package version\n\n.. image:: https://img.shields.io/pypi/pyversions/typepy.svg\n    :target: https://pypi.org/project/typepy\n    :alt: Supported Python versions\n\n.. image:: https://img.shields.io/pypi/implementation/typepy.svg\n    :target: https://pypi.org/project/typepy\n    :alt: Supported Python implementations\n\n.. image:: https://github.com/thombashi/typepy/workflows/Tests/badge.svg\n    :target: https://github.com/thombashi/typepy/actions?query=workflow%3ATests\n    :alt: Linux/macOS/Windows CI status\n\n.. image:: https://coveralls.io/repos/github/thombashi/typepy/badge.svg?branch=master\n    :target: https://coveralls.io/github/thombashi/typepy?branch=master\n    :alt: Test coverage\n\n.. image:: https://github.com/thombashi/typepy/actions/workflows/github-code-scanning/codeql/badge.svg\n    :target: https://github.com/thombashi/typepy/actions/workflows/github-code-scanning/codeql\n    :alt: CodeQL\n\nFeatures\n==========\n- checking a value type\n- validate a value for a type\n- convert a value from one type to the other type\n\nThe correspondence between Python types and ``typepy`` classes are as follows:\n\n.. table:: Supported Types\n\n    ================================================  =======================================================================================================\n    Python Type                                       typepy: Type Class\n    ================================================  =======================================================================================================\n    ``bool``                                          `Bool \u003chttps://typepy.rtfd.io/en/latest/pages/reference/type.html#bool-type\u003e`__\n    ``datetime``                                      `DateTime \u003chttps://typepy.rtfd.io/en/latest/pages/reference/type.html#datetime-type\u003e`__\n    ``dict``                                          `Dictionary \u003chttps://typepy.rtfd.io/en/latest/pages/reference/type.html#dictionary-type\u003e`__\n    ``float``/``decimal.Decimal`` (not infinity/NaN)  `RealNumber \u003chttps://typepy.rtfd.io/en/latest/pages/reference/type.html#real-number-type\u003e`__\n    ``float``/``decimal.Decimal`` (infinity)          `Infinity \u003chttps://typepy.rtfd.io/en/latest/pages/reference/type.html#infinity-type\u003e`__\n    ``float``/``decimal.Decimal`` (NaN)               `Nan \u003chttps://typepy.rtfd.io/en/latest/pages/reference/type.html#nan-type\u003e`__\n    ``int``                                           `Integer \u003chttps://typepy.rtfd.io/en/latest/pages/reference/type.html#integer-type\u003e`__\n    ``list``                                          `List \u003chttps://typepy.rtfd.io/en/latest/pages/reference/type.html#list-type\u003e`__\n    ``None``                                          `None \u003chttps://typepy.rtfd.io/en/latest/pages/reference/type.html#none-type\u003e`__\n    ``str`` (not null)                                `String \u003chttps://typepy.rtfd.io/en/latest/pages/reference/type.html#string-type\u003e`__\n    ``str`` (null)                                    `NullString \u003chttps://typepy.rtfd.io/en/latest/pages/reference/type.html#null-string-type\u003e`__\n    ``str`` (IP address)                              `IpAddress \u003chttps://typepy.rtfd.io/en/latest/pages/reference/type.html#ip-address-type\u003e`__\n    ================================================  =======================================================================================================\n\nInstallation\n============\n\nInstallation: pip\n------------------------------\n::\n\n    pip install typepy\n\nInstall additional dependency packages with the following command if using ``typepy.DateTime`` class\n\n::\n\n    pip install typepy[datetime]\n\nInstallation: conda\n------------------------------\n::\n\n    conda install -c conda-forge typepy\n\nInstallation: apt\n------------------------------\n::\n\n    sudo add-apt-repository ppa:thombashi/ppa\n    sudo apt update\n    sudo apt install python3-typepy\n\n\nDependencies\n============\n- Python 3.9+\n- `Python package dependencies (automatically installed) \u003chttps://github.com/thombashi/typepy/network/dependencies\u003e`__\n\nOptional dependencies\n----------------------------------\nThese packages can be installed via ``pip install typepy[datetime]``:\n\n- `python-dateutil \u003chttps://dateutil.readthedocs.io/en/stable/\u003e`__\n- `pytz \u003chttps://pypi.org/project/pytz/\u003e`__\n\nUsage\n=======\nType Check Method\n----------------------\n:Examples:\n    .. code-block:: pycon\n\n        \u003e\u003e\u003e from typepy import Integer\n        \u003e\u003e\u003e Integer(1).is_type()\n        True\n        \u003e\u003e\u003e Integer(1.1).is_type()\n        False\n\n\nType Validation Method\n--------------------------------------------\n:Examples:\n    .. code-block:: pycon\n\n        \u003e\u003e\u003e from typepy import Integer\n        \u003e\u003e\u003e Integer(1).validate()\n        \u003e\u003e\u003e try:\n        ...     Integer(1.1).validate()\n        ... except TypeError as e:\n        ...     # validate() raised TypeError when the value unmatched the type class\n        ...     print(e)\n        ...\n        invalid value type: expected=INTEGER, actual=\u003ctype 'float'\u003e\n\n\nType Conversion Methods\n--------------------------------------------\n\nconvert method\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n:Examples:\n    .. code-block:: pycon\n\n        \u003e\u003e\u003e from typepy import Integer, TypeConversionError\n        \u003e\u003e\u003e Integer(\"1\").convert()\n        1\n        \u003e\u003e\u003e try:\n        ...     Integer(1.1).convert()\n        ... except TypeConversionError as e:\n        ...     # convert() raised TypeConversionError when conversion failed\n        ...     print(e)\n        ...\n        failed to convert from float to INTEGER\n\ntry_convert method\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n:Examples:\n    .. code-block:: pycon\n\n        \u003e\u003e\u003e from typepy import Integer\n        \u003e\u003e\u003e Integer(\"1\").try_convert()\n        1\n        \u003e\u003e\u003e print(Integer(1.1).try_convert())  # try_convert() returned None when conversion failed\n        None\n\nforce_convert\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n:Examples:\n    .. code-block:: pycon\n\n        \u003e\u003e\u003e from typepy import Integer, TypeConversionError\n        \u003e\u003e\u003e Integer(\"1\").force_convert()  # force_convert() forcibly convert the value\n        1\n        \u003e\u003e\u003e Integer(1.1).force_convert()\n        1\n        \u003e\u003e\u003e try:\n        ...     Integer(\"abc\").force_convert()\n        ... except TypeConversionError as e:\n        ...     # force_convert() raised TypeConversionError when the value was not convertible\n        ...     print(e)\n        ...\n        failed to force_convert to int: type=\u003cclass 'str'\u003e\n\n\nFor more information\n--------------------------------------------\nType check/validate/convert results differed according to\n``strict_level`` value which can pass to typepy class constructors as an argument.\nMore information can be found in the\n`API reference \u003chttps://typepy.rtfd.io/en/latest/pages/reference/index.html\u003e`__.\n\nDocumentation\n===============\nhttps://typepy.rtfd.io/\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthombashi%2Ftypepy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthombashi%2Ftypepy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthombashi%2Ftypepy/lists"}