Python objects metadata parser.
Project description
paradigm
In what follows
python
is an alias forpython3.5
or any later version (python3.6
and so on),pypy
is an alias forpypy3.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:
- 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
>>> signatures.factory(any)
# CPython
Plain(Parameter(name='iterable', kind=Parameter.Kind.POSITIONAL_ONLY, has_default=False))
# PyPy
Plain(Parameter(name='seq', kind=Parameter.Kind.POSITIONAL_OR_KEYWORD, has_default=False))
for built-in classes
>>> signatures.factory(float)
# CPython
Plain(Parameter(name='x', kind=Parameter.Kind.POSITIONAL_ONLY, has_default=True))
# PyPy
Plain(Parameter(name='x', kind=Parameter.Kind.POSITIONAL_OR_KEYWORD, has_default=True))
for built-in classes methods
>>> signatures.factory(float.as_integer_ratio)
# CPython
Plain(Parameter(name='self', kind=Parameter.Kind.POSITIONAL_ONLY, has_default=False))
# PyPy
Plain(Parameter(name='self', kind=Parameter.Kind.POSITIONAL_OR_KEYWORD, has_default=False))
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
.
Notes
To avoid inconsistency between branches and pull requests,
bumping version should be merged into master
branch as separate pull
request.
Running tests
Plain:
- with
CPython
python setup.py test
- with
PyPy
pypy setup.py test
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file paradigm-0.2.4.tar.gz
.
File metadata
- Download URL: paradigm-0.2.4.tar.gz
- Upload date:
- Size: 20.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 551bb6f6de8ea8c6202e0b83ec20b248e19031044d40973b15e203c41abc2b7d |
|
MD5 | fe92c77b9368a4e4eaaf1416da68d38c |
|
BLAKE2b-256 | 3c37d8ae4eea7765e2fcdcb1f714ebb393eff5b8bb63fa54f16ea173ea20b843 |
File details
Details for the file paradigm-0.2.4-py3-none-any.whl
.
File metadata
- Download URL: paradigm-0.2.4-py3-none-any.whl
- Upload date:
- Size: 29.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92e19e3788fc0e497b34745dde3ba9f5494c0fcd50084a056f8b0b58ac03edfd |
|
MD5 | dbecb7a1c640cb8655823812bbad082b |
|
BLAKE2b-256 | c6600eaac2e44b051fc04a3dbf316c6c074550b86b9378e426537fc638367894 |