Skip to content

Commit

Permalink
Merge pull request #57 from ikalnytskyi/chore/up-to-date
Browse files Browse the repository at this point in the history
Set of minor changes to keep the project up to date
  • Loading branch information
ikalnytskyi authored Apr 2, 2023
2 parents e92b001 + 6b5cd84 commit ebcc39f
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 123 deletions.
16 changes: 7 additions & 9 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,21 @@ jobs:
pypi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v2

- name: Setup dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade twine
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Prepare artifacts
run: |
python setup.py sdist
pipx run -- hatch build
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
twine upload dist/*
pipx run -- twine upload dist/*
57 changes: 21 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,61 +10,46 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v2

- name: Setup dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade tox
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Run lints
run: |
python -m tox -e pre-commit
run: pipx run -- hatch run lint:run

test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ["3.7", "3.8", "3.9", "3.10", "pypy-3.8"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "pypy-3.8"]

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Checkout repository
uses: actions/checkout@v3

- name: Pull OpenAPI specs for tests
run: |
git submodule update --init --recursive
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Setup dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade tox
- name: Run pytest
run: |
python -m tox -e py
- name: Run pytest
run: pipx run -- hatch run test:run

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v2

- name: Setup dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade tox
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Run sphinx
run: |
python -m tox -e docs
run: pipx run -- hatch run docs:run
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
args: [--profile=black, --filter-files]
Expand All @@ -11,12 +11,12 @@ repos:
files: tests/

- repo: https://github.com/psf/black
rev: 22.1.0
rev: 23.3.0
hooks:
- id: black

- repo: https://gitlab.com/pycqa/flake8
rev: 4.0.1
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
args: ["--max-line-length=99", "--extend-ignore=E203"]
Expand All @@ -25,7 +25,7 @@ repos:
- flake8-implicit-str-concat

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.4.0
hooks:
- id: check-yaml
- id: check-case-conflict
Expand Down
4 changes: 3 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ Release Notes

(unreleased)

* Add ``Python 3.10`` support.
* Add ``Python 3.10`` & `Python 3.11` support.

* Drop ``Python 2.7`` support. It's dead for more than a year anyway. Those who
want to use picobox with ``Python 2`` should stick with ``2.x`` branch.
Expand All @@ -369,6 +369,8 @@ Release Notes
* Make some parameters keyword-only: ``factory`` and ``scope`` in ``Box.put()``,
``as_`` in ``Box.pass_()`` and ``chain`` in ``picobox.push()``.

* Use `PEP 621 <https://peps.python.org/pep-0621/>`_ ``pyproject.toml`` in
a so-called source distribution.

2.2.0
`````
Expand Down
1 change: 0 additions & 1 deletion examples/classes/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ def send(self, text):


class Controller:

# Picobox supports injections by type (key may be any hashable object),
# though in this case you have to explicitly map the key onto argument
# name.
Expand Down
50 changes: 50 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[project]
name = "picobox"
description = "Dependency injection framework designed with Python in mind."
readme = "README.rst"
requires-python = ">=3.7"
license = "MIT"
authors = [
{ name = "Ihor Kalnytskyi", email = "[email protected]" },
]
classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Libraries",
]
dynamic = ["version"]

[project.urls]
Documentation = "https://picobox.readthedocs.io"
Source = "https://github.com/ikalnytskyi/picobox"
Bugs = "https://github.com/ikalnytskyi/picobox/issues"

[tool.hatch.version]
source = "vcs"

[tool.hatch.envs.test]
dependencies = ["pytest", "flask"]
scripts.run = "python -m pytest --strict {args:-vv}"

[tool.hatch.envs.lint]
detached = true
dependencies = ["pre-commit"]
scripts.run = "python -m pre_commit run --all-files --show-diff-on-failure"

[tool.hatch.envs.docs]
dependencies = ["sphinx", "sphinx_rtd_theme"]
scripts.run = "sphinx-build -W -b html docs docs/_build/"
46 changes: 0 additions & 46 deletions setup.py

This file was deleted.

12 changes: 9 additions & 3 deletions tests/test_scopes.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,19 @@ def target():
@pytest.fixture(scope="function")
def exec_coroutine(request):
"""Run a given coroutine function in a separate event loop."""

asyncio = pytest.importorskip("asyncio")
loop = asyncio.new_event_loop()
request.addfinalizer(loop.close)

def executor(coroutine_function, *args, **kwargs):
if not asyncio.iscoroutinefunction(coroutine_function):
coroutine_function = asyncio.coroutine(coroutine_function)
def executor(function, *args, **kwargs):
if not asyncio.iscoroutinefunction(function):

async def coroutine_function(*args, **kwargs):
return function(*args, **kwargs)

else:
coroutine_function = function
return loop.run_until_complete(coroutine_function(*args, **kwargs))

return executor
Expand Down
22 changes: 0 additions & 22 deletions tox.ini

This file was deleted.

0 comments on commit ebcc39f

Please sign in to comment.