Skip to main content

Python objects metadata parser.

Project description

paradigm

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

Installation

Install the latest pip & setuptools packages versions

python -m pip install --upgrade pip setuptools

User

Download and install the latest stable version from PyPI repository

python -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

python -m pip install -r requirements.txt

Install

python setup.py install

Usage

With setup

>>> import typing
>>> from paradigm.base import (Parameter,
...                            PlainSignature,
...                            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: bool = False, **kwargs: str) -> None:
...     pass

we can obtain a signature of

  • user-defined functions
    >>> signature_from_callable(func) == PlainSignature(
    ...     Parameter(annotation=int,
    ...               has_default=False,
    ...               kind=Parameter.Kind.POSITIONAL_OR_KEYWORD,
    ...               name='foo'),
    ...     Parameter(annotation=bool,
    ...               has_default=True,
    ...               kind=Parameter.Kind.POSITIONAL_OR_KEYWORD,
    ...               name='bar'),
    ...     Parameter(annotation=str,
    ...               has_default=False,
    ...               kind=Parameter.Kind.VARIADIC_KEYWORD,
    ...               name='kwargs'),
    ...     returns=None
    ... )
    True
    
  • user-defined classes
    >>> signature_from_callable(UpperOut) == PlainSignature(
    ...     Parameter(annotation=typing.IO[typing.AnyStr],
    ...               has_default=False,
    ...               kind=Parameter.Kind.POSITIONAL_OR_KEYWORD,
    ...               name='outfile'),
    ...     returns=Self
    ... )
    True
    
  • user-defined classes methods
    >>> signature_from_callable(UpperOut.write) == PlainSignature(
    ...     Parameter(annotation=typing.Any,
    ...               has_default=False,
    ...               kind=Parameter.Kind.POSITIONAL_OR_KEYWORD,
    ...               name='self'),
    ...     Parameter(annotation=typing.AnyStr,
    ...               has_default=False,
    ...               kind=Parameter.Kind.POSITIONAL_OR_KEYWORD,
    ...               name='s'),
    ...     returns=None
    ... )
    True
    
  • built-in functions
    >>> signature_from_callable(any) == PlainSignature(
    ...     Parameter(annotation=typing.Iterable[object],
    ...               has_default=False,
    ...               kind=Parameter.Kind.POSITIONAL_ONLY,
    ...               name='__iterable'),
    ...     returns=bool
    ... )
    True
    
  • built-in classes
    >>> signature_from_callable(bool) == PlainSignature(
    ...     Parameter(annotation=object,
    ...               has_default=True,
    ...               kind=Parameter.Kind.POSITIONAL_ONLY,
    ...               name='__o'),
    ...     returns=Self
    ... )
    True
    
  • built-in classes methods
    >>> signature_from_callable(float.hex) == PlainSignature(
    ...     Parameter(annotation=Self,
    ...               has_default=False,
    ...               kind=Parameter.Kind.POSITIONAL_ONLY,
    ...               name='self'),
    ...     returns=str
    ... )
    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

python -m pip install -r requirements-tests.txt

PlainSignature

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-1.0.0.tar.gz (32.6 kB view details)

Uploaded Source

Built Distribution

paradigm-1.0.0-py3-none-any.whl (38.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: paradigm-1.0.0.tar.gz
  • Upload date:
  • Size: 32.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for paradigm-1.0.0.tar.gz
Algorithm Hash digest
SHA256 eb4331695f658e013b2509cdd998c990d1c7cc5010984e66f727a0928f2abf08
MD5 e2616226372b66f9065fb36ba6f9423c
BLAKE2b-256 a2118a5458cb914c63b7027093c22b3545383957c07766fe13e53c26a808bf4a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: paradigm-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 38.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for paradigm-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 379b5dd1671a41a073bdaff0864efafdadc51eb6f2a5cd58b828861e9dff646e
MD5 4d20102cff38c978d04f0087f922d557
BLAKE2b-256 106db078e8455dc530b3d43395273e591b8861853d8759f4437e60d8b0bcbf9b

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