Skip to content

Commit

Permalink
Downgrade pylint, add rc file
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanUlbrich committed Mar 8, 2022
1 parent 8eb9b8d commit 094da3c
Show file tree
Hide file tree
Showing 4 changed files with 596 additions and 35 deletions.
13 changes: 3 additions & 10 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
A minimalistic decorator for the [design by contract pattern](https://en.wikipedia.org/wiki/Design_by_contract)
written in a just little more than 100 lines of modern Python 3.10 code (not counting documentation and logging).



Contracts are useful to impose restrictions and constraints on function arguments in a way that

* reduces boilerplate for argument validation in the function body
Expand All @@ -26,7 +24,6 @@ You probably shouldn't use it in production yet! But if you do, let me know how

## Application


The decorator has been mainly designed with [numpy arrays](https://numpy.org) and [pandas DataFrames](https://pandas.pydata.org/)
in mind but can be universally applied.
Contracts are defined as lambda functions that are attached to the function arguments via the
Expand All @@ -35,7 +32,6 @@ to the arguments' and return value's type hint. Arguments are inserted into the
[dependency injection](https://en.wikipedia.org/wiki/Dependency_injection) and working with
symbols to increase readability is supported.


Let's look at an example for for matrix multiplication!

```python
Expand Down Expand Up @@ -65,7 +61,6 @@ def spam(
return a @ b
```


Symbolic calculus is supported to certain degree to make your life easier. The symbols `m`, `n` and `o` are defined in a way
that

Expand Down Expand Up @@ -111,7 +106,6 @@ spam(np.zeros((3, 2)), np.zeros(( 4, 2)))

The decorator is also quite handy for being used with pandas data frames:


```python
@contract
def spam(a: Annotated[pd.DataFrame,
Expand All @@ -132,7 +126,6 @@ spam(a, b)
Note that evaluation is not optimized. In production, you might consider disabling evaluation by passing
`evaluate=False` as a parameter to the `contract` decorator.


## Features

* [x] Simple to used design by contract. Does not require you to learn a domain specific language necessary.
Expand All @@ -152,6 +145,8 @@ Note that evaluation is not optimized. In production, you might consider disabli
* [x] Currently only one runtime dependency!
* [x] Documentation using [sphinx](https://www.sphinx-doc.org/en/master/), [myst](https://myst-parser.readthedocs.io/en/latest/index.html) and [sphinx book](https://sphinx-book-theme.readthedocs.io/en/stable/)
* [x] Tested with pytest
* [x] Type annotations
* [x] code formatted ([black](https://github.com/psf/black)), linted ([pylint](https://pylint.org/)). Linting with [mypy](http://www.mypy-lang.org/) does not support pattern matching yet.
* [ ] Speed. Well.. maybe. I haven't tested it yet.

## Why?
Expand All @@ -164,7 +159,7 @@ might serve as an example for new Python developers:

If you think it's cool, please leave a star. And who knows, it might actually be useful.

## Related (active) projects.
## Related (active) projects

It appears that the related (still active) projects have significantly larger code bases
(include parsers for a domain-specific language, automated testing, etc.) but also try to achieve
Expand Down Expand Up @@ -203,5 +198,3 @@ Pull requests are welcome!
## License

MIT License, Copyright 2022 Stefan Ulbrich


48 changes: 24 additions & 24 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 094da3c

Please sign in to comment.