Skip to content

Commit

Permalink
use pw to auto-install tools and fix type hints (#91)
Browse files Browse the repository at this point in the history
* use pw to auto-install tools and fix type hints

* use pytest as testrunner

* use ruff as formatter and linter + fix trivial lint errors

* replace setuptools with flit and add build action

* remove mypy type checking from pre-commit hook because it take too long

* bumped version

---------

Co-authored-by: ihoubr <[email protected]>
  • Loading branch information
houbie and ihoubr committed Feb 14, 2024
1 parent 469f2ca commit d7fd541
Show file tree
Hide file tree
Showing 16 changed files with 803 additions and 722 deletions.
38 changes: 0 additions & 38 deletions .github/workflows/actions.yml

This file was deleted.

38 changes: 38 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: pybreaker test matrix

on:
push:
branches: [main]
pull_request:
workflow_dispatch:

jobs:
build:
name: Build Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]

steps:
- uses: actions/checkout@v3

- name: Cache pyprojectx
uses: actions/cache@v4
with:
key: ${{ hashFiles('pyproject.toml') }}-${{ matrix.python-version }}-venvs
path: |
.pyprojectx
venv
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Test and build
run: |
./pw lint
./pw type-check
./pw test
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
# tox
.tox

.python-version

# Build directories
build/
dist/
*.egg-info/
.eggs/
.pyprojectx/

# Pycharm directories
# Pycharm directories
.idea
.ropeproject/
*.iml
Expand Down
31 changes: 20 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
repos:
- repo: https://github.com/psf/black
rev: 22.6.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.10.1
- id: trailing-whitespace
- id: end-of-file-fixer
- id: fix-byte-order-marker

- repo: local
hooks:
- id: isort
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.971
- id: format
name: format
entry: pw format
language: script
types: [ python ]
pass_filenames: false

- repo: local
hooks:
- id: mypy
- id: lint
name: lint
entry: pw lint
language: script
types: [ python ]
pass_filenames: false
additional_dependencies:
- "types-redis"
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

Version 1.2.0 (February ??, 2024)

* Fixed type hints
* Improved building and testing
* Dropped support for Python 3.7

Version 1.1.0 (January 09, 2024)

* Added calling() method to CircuitBreaker, returning a context manager (Thanks @martijnthe)
Expand Down
31 changes: 25 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Features
Requirements
------------

* `Python`_ 3.7+
* `Python`_ 3.8+


Installation
Expand All @@ -38,13 +38,14 @@ PyBreaker from `PyPI`_::

$ pip install pybreaker

If you are a `Git`_ user, you might want to download the current development
version::
If you are a `Git`_ user, you might want to install the current development
version in editable mode::

$ git clone git://github.com/danielfm/pybreaker.git
$ cd pybreaker
$ python setup.py test
$ python setup.py install
$ # run tests (on windows omit ./)
$ ./pw test
$ pip install -e .


Usage
Expand Down Expand Up @@ -108,7 +109,7 @@ fail with:
.. note::

If you require multiple, independent CircuitBreakers and wish to store their states in Redis, it is essential to assign a ``unique namespace`` for each
If you require multiple, independent CircuitBreakers and wish to store their states in Redis, it is essential to assign a ``unique namespace`` for each
CircuitBreaker instance. This can be achieved by specifying a distinct namespace parameter in the CircuitRedisStorage constructor. for example:

.. code:: python
Expand Down Expand Up @@ -318,6 +319,24 @@ change its current state:
These properties and functions might and should be exposed to the operations
staff somehow as they help them to detect problems in the system.

Contributing
-------------

Run tests::

$ ./pw test

Code formatting (black and isort) and linting (mypy) ::

$ ./pw format
$ ./pw lint

Above commands will automatically install the necessary tools inside *.pyprojectx*
and also install pre-commit hooks.

List available commands::

$ ./pw -i

.. _Python: http://python.org
.. _Jython: http://jython.org
Expand Down
Loading

0 comments on commit d7fd541

Please sign in to comment.