paradigm


Nameparadigm JSON
Version 4.2.0 PyPI version JSON
download
home_pagehttps://github.com/lycantropos/paradigm/
SummaryPython objects metadata parser.
upload_time2023-06-24 13:32:10
maintainer
docs_urlNone
author
requires_python>=3.7
licenseMIT License Copyright (c) 2018 Azat Ibrakov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            paradigm
========

[![](https://github.com/lycantropos/paradigm/workflows/CI/badge.svg)](https://github.com/lycantropos/paradigm/actions/workflows/ci.yml "Github Actions")
[![](https://codecov.io/gh/lycantropos/paradigm/branch/master/graph/badge.svg)](https://codecov.io/gh/lycantropos/paradigm "Codecov")
[![](https://img.shields.io/github/license/lycantropos/paradigm.svg)](https://github.com/lycantropos/paradigm/blob/master/LICENSE "License")
[![](https://badge.fury.io/py/paradigm.svg)](https://badge.fury.io/py/paradigm "PyPI")

In what follows `python` is an alias for `python3.7` or `pypy3.7`
or any later version (`python3.8`, `pypy3.8` and so on).

Installation
------------

Install the latest `pip` & `setuptools` packages versions
```bash
python -m pip install --upgrade pip setuptools
```

### User

Download and install the latest stable version from `PyPI` repository
```bash
python -m pip install --upgrade paradigm
```

### Developer

Download the latest version from `GitHub` repository
```bash
git clone https://github.com/lycantropos/paradigm.git
cd paradigm
```

Install dependencies
```bash
python -m pip install -r requirements.txt
```

Install
```bash
python setup.py install
```

Usage
-----

With setup
```python
>>> import typing
>>> from paradigm.base import (OptionalParameter,
...                            ParameterKind,
...                            PlainSignature,
...                            RequiredParameter,
...                            signature_from_callable)
>>> from typing_extensions import Self
>>> class UpperOut:
...     def __init__(self, outfile: typing.IO[typing.AnyStr]) -> None:
...         self._outfile = outfile
... 
...     def write(self, s: typing.AnyStr) -> None:
...         self._outfile.write(s.upper())
... 
...     def __getattr__(self, name: str) -> typing.Any:
...         return getattr(self._outfile, name)
>>> def func(foo: int, bar: float, *, baz: bool = False, **kwargs: str) -> None:
...     pass

```
we can obtain a signature of
- user-defined functions
  ```python
  >>> signature_from_callable(func) == PlainSignature(
  ...     RequiredParameter(annotation=int,
  ...                       kind=ParameterKind.POSITIONAL_OR_KEYWORD,
  ...                       name='foo'),
  ...     RequiredParameter(annotation=float,
  ...                       kind=ParameterKind.POSITIONAL_OR_KEYWORD,
  ...                       name='bar'),
  ...     OptionalParameter(annotation=bool,
  ...                       default=False,
  ...                       kind=ParameterKind.KEYWORD_ONLY,
  ...                       name='baz'),
  ...     OptionalParameter(annotation=str,
  ...                       kind=ParameterKind.VARIADIC_KEYWORD,
  ...                       name='kwargs'),
  ...     returns=None
  ... )
  True
  
  ```
- user-defined classes
  ```python
  >>> signature_from_callable(UpperOut) == PlainSignature(
  ...     RequiredParameter(annotation=typing.IO[typing.AnyStr],
  ...                       kind=ParameterKind.POSITIONAL_OR_KEYWORD,
  ...                       name='outfile'),
  ...     returns=Self
  ... )
  True
  
  ```
- user-defined classes methods
  ```python
  >>> signature_from_callable(UpperOut.write) == PlainSignature(
  ...     RequiredParameter(annotation=typing.Any,
  ...                       kind=ParameterKind.POSITIONAL_OR_KEYWORD,
  ...                       name='self'),
  ...     RequiredParameter(annotation=typing.AnyStr,
  ...                       kind=ParameterKind.POSITIONAL_OR_KEYWORD,
  ...                       name='s'),
  ...     returns=None
  ... )
  True
  
  ```
- built-in functions
  ```python
  >>> signature_from_callable(any) == PlainSignature(
  ...     RequiredParameter(annotation=typing.Iterable[object],
  ...                       kind=ParameterKind.POSITIONAL_ONLY,
  ...                       name='__iterable'),
  ...     returns=bool
  ... )
  True
  
  ```
- built-in classes
  ```python
  >>> signature_from_callable(bool) == PlainSignature(
  ...     OptionalParameter(annotation=object,
  ...                       kind=ParameterKind.POSITIONAL_ONLY,
  ...                       name='__o'),
  ...     returns=Self
  ... )
  True
  
  ```
- built-in classes methods
  ```python
  >>> signature_from_callable(float.hex) == PlainSignature(
  ...     RequiredParameter(annotation=Self,
  ...                       kind=ParameterKind.POSITIONAL_ONLY,
  ...                       name='self'),
  ...     returns=str
  ... )
  True
  
  ```

Development
-----------

### Bumping version

#### Preparation

Install
[bump2version](https://github.com/c4urself/bump2version#installation).

#### Pre-release

Choose which version number category to bump following [semver
specification](http://semver.org/).

Test bumping version
```bash
bump2version --dry-run --verbose $CATEGORY
```

where `$CATEGORY` is the target version number category name, possible
values are `patch`/`minor`/`major`.

Bump version
```bash
bump2version --verbose $CATEGORY
```

This will set version to `major.minor.patch-alpha`. 

#### Release

Test bumping version
```bash
bump2version --dry-run --verbose release
```

Bump version
```bash
bump2version --verbose release
```

This will set version to `major.minor.patch`.

### Running tests

Install dependencies
```bash
python -m pip install -r requirements-tests.txt
```

PlainSignature
```bash
pytest
```

Inside `Docker` container:
- with `CPython`
  ```bash
  docker-compose --file docker-compose.cpython.yml up
  ```
- with `PyPy`
  ```bash
  docker-compose --file docker-compose.pypy.yml up
  ```

`Bash` script (e.g. can be used in `Git` hooks):
- with `CPython`
  ```bash
  ./run-tests.sh
  ```
  or
  ```bash
  ./run-tests.sh cpython
  ```

- with `PyPy`
  ```bash
  ./run-tests.sh pypy
  ```

`PowerShell` script (e.g. can be used in `Git` hooks):
- with `CPython`
  ```powershell
  .\run-tests.ps1
  ```
  or
  ```powershell
  .\run-tests.ps1 cpython
  ```
- with `PyPy`
  ```powershell
  .\run-tests.ps1 pypy
  ```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/lycantropos/paradigm/",
    "name": "paradigm",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "",
    "author_email": "Azat Ibrakov <azatibrakov@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/c1/e6/078fe0e92195ae4bedbf4e9275b50fad64fbc7e692e7203ae0e326988f22/paradigm-4.2.0.tar.gz",
    "platform": null,
    "description": "paradigm\n========\n\n[![](https://github.com/lycantropos/paradigm/workflows/CI/badge.svg)](https://github.com/lycantropos/paradigm/actions/workflows/ci.yml \"Github Actions\")\n[![](https://codecov.io/gh/lycantropos/paradigm/branch/master/graph/badge.svg)](https://codecov.io/gh/lycantropos/paradigm \"Codecov\")\n[![](https://img.shields.io/github/license/lycantropos/paradigm.svg)](https://github.com/lycantropos/paradigm/blob/master/LICENSE \"License\")\n[![](https://badge.fury.io/py/paradigm.svg)](https://badge.fury.io/py/paradigm \"PyPI\")\n\nIn what follows `python` is an alias for `python3.7` or `pypy3.7`\nor any later version (`python3.8`, `pypy3.8` and so on).\n\nInstallation\n------------\n\nInstall the latest `pip` & `setuptools` packages versions\n```bash\npython -m pip install --upgrade pip setuptools\n```\n\n### User\n\nDownload and install the latest stable version from `PyPI` repository\n```bash\npython -m pip install --upgrade paradigm\n```\n\n### Developer\n\nDownload the latest version from `GitHub` repository\n```bash\ngit clone https://github.com/lycantropos/paradigm.git\ncd paradigm\n```\n\nInstall dependencies\n```bash\npython -m pip install -r requirements.txt\n```\n\nInstall\n```bash\npython setup.py install\n```\n\nUsage\n-----\n\nWith setup\n```python\n>>> import typing\n>>> from paradigm.base import (OptionalParameter,\n...                            ParameterKind,\n...                            PlainSignature,\n...                            RequiredParameter,\n...                            signature_from_callable)\n>>> from typing_extensions import Self\n>>> class UpperOut:\n...     def __init__(self, outfile: typing.IO[typing.AnyStr]) -> None:\n...         self._outfile = outfile\n... \n...     def write(self, s: typing.AnyStr) -> None:\n...         self._outfile.write(s.upper())\n... \n...     def __getattr__(self, name: str) -> typing.Any:\n...         return getattr(self._outfile, name)\n>>> def func(foo: int, bar: float, *, baz: bool = False, **kwargs: str) -> None:\n...     pass\n\n```\nwe can obtain a signature of\n- user-defined functions\n  ```python\n  >>> signature_from_callable(func) == PlainSignature(\n  ...     RequiredParameter(annotation=int,\n  ...                       kind=ParameterKind.POSITIONAL_OR_KEYWORD,\n  ...                       name='foo'),\n  ...     RequiredParameter(annotation=float,\n  ...                       kind=ParameterKind.POSITIONAL_OR_KEYWORD,\n  ...                       name='bar'),\n  ...     OptionalParameter(annotation=bool,\n  ...                       default=False,\n  ...                       kind=ParameterKind.KEYWORD_ONLY,\n  ...                       name='baz'),\n  ...     OptionalParameter(annotation=str,\n  ...                       kind=ParameterKind.VARIADIC_KEYWORD,\n  ...                       name='kwargs'),\n  ...     returns=None\n  ... )\n  True\n  \n  ```\n- user-defined classes\n  ```python\n  >>> signature_from_callable(UpperOut) == PlainSignature(\n  ...     RequiredParameter(annotation=typing.IO[typing.AnyStr],\n  ...                       kind=ParameterKind.POSITIONAL_OR_KEYWORD,\n  ...                       name='outfile'),\n  ...     returns=Self\n  ... )\n  True\n  \n  ```\n- user-defined classes methods\n  ```python\n  >>> signature_from_callable(UpperOut.write) == PlainSignature(\n  ...     RequiredParameter(annotation=typing.Any,\n  ...                       kind=ParameterKind.POSITIONAL_OR_KEYWORD,\n  ...                       name='self'),\n  ...     RequiredParameter(annotation=typing.AnyStr,\n  ...                       kind=ParameterKind.POSITIONAL_OR_KEYWORD,\n  ...                       name='s'),\n  ...     returns=None\n  ... )\n  True\n  \n  ```\n- built-in functions\n  ```python\n  >>> signature_from_callable(any) == PlainSignature(\n  ...     RequiredParameter(annotation=typing.Iterable[object],\n  ...                       kind=ParameterKind.POSITIONAL_ONLY,\n  ...                       name='__iterable'),\n  ...     returns=bool\n  ... )\n  True\n  \n  ```\n- built-in classes\n  ```python\n  >>> signature_from_callable(bool) == PlainSignature(\n  ...     OptionalParameter(annotation=object,\n  ...                       kind=ParameterKind.POSITIONAL_ONLY,\n  ...                       name='__o'),\n  ...     returns=Self\n  ... )\n  True\n  \n  ```\n- built-in classes methods\n  ```python\n  >>> signature_from_callable(float.hex) == PlainSignature(\n  ...     RequiredParameter(annotation=Self,\n  ...                       kind=ParameterKind.POSITIONAL_ONLY,\n  ...                       name='self'),\n  ...     returns=str\n  ... )\n  True\n  \n  ```\n\nDevelopment\n-----------\n\n### Bumping version\n\n#### Preparation\n\nInstall\n[bump2version](https://github.com/c4urself/bump2version#installation).\n\n#### Pre-release\n\nChoose which version number category to bump following [semver\nspecification](http://semver.org/).\n\nTest bumping version\n```bash\nbump2version --dry-run --verbose $CATEGORY\n```\n\nwhere `$CATEGORY` is the target version number category name, possible\nvalues are `patch`/`minor`/`major`.\n\nBump version\n```bash\nbump2version --verbose $CATEGORY\n```\n\nThis will set version to `major.minor.patch-alpha`. \n\n#### Release\n\nTest bumping version\n```bash\nbump2version --dry-run --verbose release\n```\n\nBump version\n```bash\nbump2version --verbose release\n```\n\nThis will set version to `major.minor.patch`.\n\n### Running tests\n\nInstall dependencies\n```bash\npython -m pip install -r requirements-tests.txt\n```\n\nPlainSignature\n```bash\npytest\n```\n\nInside `Docker` container:\n- with `CPython`\n  ```bash\n  docker-compose --file docker-compose.cpython.yml up\n  ```\n- with `PyPy`\n  ```bash\n  docker-compose --file docker-compose.pypy.yml up\n  ```\n\n`Bash` script (e.g. can be used in `Git` hooks):\n- with `CPython`\n  ```bash\n  ./run-tests.sh\n  ```\n  or\n  ```bash\n  ./run-tests.sh cpython\n  ```\n\n- with `PyPy`\n  ```bash\n  ./run-tests.sh pypy\n  ```\n\n`PowerShell` script (e.g. can be used in `Git` hooks):\n- with `CPython`\n  ```powershell\n  .\\run-tests.ps1\n  ```\n  or\n  ```powershell\n  .\\run-tests.ps1 cpython\n  ```\n- with `PyPy`\n  ```powershell\n  .\\run-tests.ps1 pypy\n  ```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2018 Azat Ibrakov  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Python objects metadata parser.",
    "version": "4.2.0",
    "project_urls": {
        "Download": "https://github.com/lycantropos/paradigm/archive/master.zip",
        "Homepage": "https://github.com/lycantropos/paradigm/"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "38c264d51376b50b7aeff8ec2cd1746930fcf324ee345efcd908b4558ad44652",
                "md5": "74b371a96ef4c5b599532c0988a78ad1",
                "sha256": "9ef96ac32faa91420de10b765da79a44b95de8eda7fe71394d677aa5220b153c"
            },
            "downloads": -1,
            "filename": "paradigm-4.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "74b371a96ef4c5b599532c0988a78ad1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 40722,
            "upload_time": "2023-06-24T13:32:09",
            "upload_time_iso_8601": "2023-06-24T13:32:09.421258Z",
            "url": "https://files.pythonhosted.org/packages/38/c2/64d51376b50b7aeff8ec2cd1746930fcf324ee345efcd908b4558ad44652/paradigm-4.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c1e6078fe0e92195ae4bedbf4e9275b50fad64fbc7e692e7203ae0e326988f22",
                "md5": "4015c27f491e4f54ea1e4c78201c8af6",
                "sha256": "3bf7d3750c914f8c60055997fb7a25579d977f24562a9bc54635946ff974f4ae"
            },
            "downloads": -1,
            "filename": "paradigm-4.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "4015c27f491e4f54ea1e4c78201c8af6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 35360,
            "upload_time": "2023-06-24T13:32:10",
            "upload_time_iso_8601": "2023-06-24T13:32:10.905947Z",
            "url": "https://files.pythonhosted.org/packages/c1/e6/078fe0e92195ae4bedbf4e9275b50fad64fbc7e692e7203ae0e326988f22/paradigm-4.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-24 13:32:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lycantropos",
    "github_project": "paradigm",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "paradigm"
}
        
Elapsed time: 0.11405s