Skip to main content

Python objects metadata parser.

Project description

paradigm

In what follows

  • python is an alias for python3.5 or any later version (python3.6 and so on),
  • pypy is an alias for pypy3.5 or any later version (pypy3.6 and so on).

Installation

Install the latest pip & setuptools packages versions:

  • with CPython
    python -m pip install --upgrade pip setuptools
    
  • with PyPy
    pypy -m pip install --upgrade pip setuptools
    

User

Download and install the latest stable version from PyPI repository:

  • with CPython
    python -m pip install --upgrade paradigm
    
  • with PyPy
    pypy -m pip install --upgrade paradigm
    

Developer

Download the latest version from GitHub repository

git clone https://github.com/lycantropos/paradigm.git
cd paradigm

Install dependencies:

  • with CPython
    python -m pip install --force-reinstall -r requirements.txt
    
  • with PyPy
    pypy -m pip install --force-reinstall -r requirements.txt
    

Install:

  • with CPython
    python setup.py install
    
  • with PyPy
    pypy setup.py install
    

Usage

paradigm can be used to obtain signature

>>> from paradigm import signatures

for user-defined functions

>>> def func(foo, bar=None, **kwargs):
...     pass
>>> signatures.factory(func)
Plain(Parameter(name='foo', kind=Parameter.Kind.POSITIONAL_OR_KEYWORD, has_default=False), Parameter(name='bar', kind=Parameter.Kind.POSITIONAL_OR_KEYWORD, has_default=True), Parameter(name='kwargs', kind=Parameter.Kind.VARIADIC_KEYWORD, has_default=False))

for user-defined classes

>>> class UpperOut:
...     def __init__(self, outfile):
...         self._outfile = outfile
... 
...     def write(self, s):
...         self._outfile.write(s.upper())
... 
...     def __getattr__(self, name):
...         return getattr(self._outfile, name)
>>> signatures.factory(UpperOut)
Plain(Parameter(name='outfile', kind=Parameter.Kind.POSITIONAL_OR_KEYWORD, has_default=False))

for user-defined classes methods

>>> signatures.factory(UpperOut.write)
Plain(Parameter(name='self', kind=Parameter.Kind.POSITIONAL_OR_KEYWORD, has_default=False), Parameter(name='s', kind=Parameter.Kind.POSITIONAL_OR_KEYWORD, has_default=False))

for built-in functions

>>> import platform
>>> from paradigm.models import Parameter, Plain
>>> signatures.factory(any) == (
...     Plain(Parameter(name='seq',
...                     kind=Parameter.Kind.POSITIONAL_OR_KEYWORD,
...                     has_default=False))
...     if platform.python_implementation() == 'PyPy'
...     else Plain(Parameter(name='iterable',
...                          kind=Parameter.Kind.POSITIONAL_ONLY,
...                          has_default=False)))
True

for built-in classes

>>> import platform
>>> from paradigm.models import Parameter, Plain
>>> signatures.factory(float) == (
...     Plain(Parameter(name='x', 
...                     kind=Parameter.Kind.POSITIONAL_OR_KEYWORD,
...                     has_default=True))
...     if platform.python_implementation() == 'PyPy'
...     else Plain(Parameter(name='x', 
...                          kind=Parameter.Kind.POSITIONAL_ONLY,
...                          has_default=True)))
True

for built-in classes methods

>>> import platform
>>> from paradigm.models import Parameter, Plain
>>> signatures.factory(float.as_integer_ratio) == (
...     Plain(Parameter(name='self',
...                     kind=Parameter.Kind.POSITIONAL_OR_KEYWORD,
...                     has_default=False))
...     if platform.python_implementation() == 'PyPy'
...     else Plain(Parameter(name='self',
...                          kind=Parameter.Kind.POSITIONAL_ONLY,
...                          has_default=False)))
True

Checking if object is supported by paradigm can be done with

>>> from paradigm import definitions
>>> definitions.is_supported(int.bit_length)
True

Development

Bumping version

Preparation

Install bump2version.

Pre-release

Choose which version number category to bump following semver specification.

Test bumping version

bump2version --dry-run --verbose $CATEGORY

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

Bump version

bump2version --verbose $CATEGORY

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

Release

Test bumping version

bump2version --dry-run --verbose release

Bump version

bump2version --verbose release

This will set version to major.minor.patch.

Running tests

Install dependencies:

  • with CPython
    python -m pip install --force-reinstall -r requirements-tests.txt
    
  • with PyPy
    pypy -m pip install --force-reinstall -r requirements-tests.txt
    

Plain

pytest

Inside Docker container:

  • with CPython
    docker-compose --file docker-compose.cpython.yml up
    
  • with PyPy
    docker-compose --file docker-compose.pypy.yml up
    

Bash script (e.g. can be used in Git hooks):

  • with CPython

    ./run-tests.sh
    

    or

    ./run-tests.sh cpython
    
  • with PyPy

    ./run-tests.sh pypy
    

PowerShell script (e.g. can be used in Git hooks):

  • with CPython
    .\run-tests.ps1
    
    or
    .\run-tests.ps1 cpython
    
  • with PyPy
    .\run-tests.ps1 pypy
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

paradigm-0.5.1.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

paradigm-0.5.1-py3-none-any.whl (29.8 kB view details)

Uploaded Python 3

File details

Details for the file paradigm-0.5.1.tar.gz.

File metadata

  • Download URL: paradigm-0.5.1.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.4

File hashes

Hashes for paradigm-0.5.1.tar.gz
Algorithm Hash digest
SHA256 e1c56357686d949e64ccf8fcd1e6dbe0718121193ef9a32a34bd89e5398a135b
MD5 f865f16a6a0adf409781bb05a73881ea
BLAKE2b-256 e6b332097fa6aab8bff093f3bba4e551fa3a657ef1229cf5a3a9b3724ee96cfd

See more details on using hashes here.

File details

Details for the file paradigm-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: paradigm-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 29.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.4

File hashes

Hashes for paradigm-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a31dd980e01efd0ca3020e617594bd766a268be58d90568dafbf608e29db28fd
MD5 25c8c5600a5e3508c49487ac46237533
BLAKE2b-256 8b31da66c2d65f858f4a25a7eacccddd07ba8caa2e7db9625ee0b7f9adeecc7d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page