Skip to content

Commit

Permalink
Merge pull request #19 from eriknw/pyproject_toml
Browse files Browse the repository at this point in the history
Modernize to use pyproject.toml and pre-commit
  • Loading branch information
eriknw committed Jun 12, 2023
2 parents 41a7bfe + b168b3b commit 4289aec
Show file tree
Hide file tree
Showing 18 changed files with 416 additions and 2,597 deletions.
14 changes: 14 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[flake8]
max-line-length = 100
inline-quotes = "
exclude =
build/
extend-ignore =
E203,
SIM105,
SIM401,
# E203 whitespace before ':' (to be compatible with black)
per-file-ignores =
__init__.py:F401
innerscope/tests/test_repr.py:E501,F821,F841
innerscope/tests/*.py:C408,C416,T201,E702,E703,F821,F841,W606
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

23 changes: 23 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Rely on pre-commit.ci
name: Lint via pre-commit

on:
workflow_dispatch:
# pull_request:
# push:
# branches-ignore:
# - main

permissions:
contents: read

jobs:
pre-commit:
name: pre-commit-hooks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: pre-commit/action@v3.0.0
5 changes: 1 addition & 4 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ jobs:
build_and_deploy:
runs-on: ubuntu-latest
if: github.repository == 'eriknw/innerscope'
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -24,7 +21,7 @@ jobs:
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build setuptools twine
python -m pip install build twine
- name: Build wheel and sdist
run: python -m build --sdist --wheel
- uses: actions/upload-artifact@v3
Expand Down
15 changes: 5 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "pypy-3.7", "pypy-3.8", "pypy-3.9"]
python-version: ["3.8", "3.9", "3.10", "3.11", "pypy-3.8", "pypy-3.9"]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -24,20 +24,14 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade pip
pip install toolz pytest coverage
pip install -e .
pip install -e . --no-deps
- name: PyTest
run: |
coverage run --branch -m pytest --doctest-modules --method bytecode
coverage run -a --branch -m pytest --doctest-modules --method trace
pytest --doctest-modules --method trace
- name: Style checks
if: (! contains(matrix.python-version, 'pypy'))
run: |
pip install black flake8
flake8 .
black innerscope *.py --check --diff
- name: Coverage
if: (! contains(matrix.python-version, 'pypy'))
env:
Expand All @@ -51,10 +45,11 @@ jobs:
finish:
needs: test
if: always()
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ __pycache__/
# Vi
*.swp
*.swo
*.swn

# Distribution / packaging
.Python
Expand Down Expand Up @@ -115,3 +116,9 @@ venv.bak/

# VSCode
.vscode

# Generated IPython notebooks
*.nbconvert.ipynb

# Dask worker
dask-worker-space/
101 changes: 101 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# https://pre-commit.com/
#
# Before first use: `pre-commit install`
# To run: `pre-commit run --all-files`
# To update: `pre-commit autoupdate`
# - &flake8_dependencies below needs updated manually
#
# Be careful about linting that rewrites code syntax we want to test.
ci:
# See: https://pre-commit.ci/#configuration
autofix_prs: false
autoupdate_schedule: quarterly
skip: [no-commit-to-branch]
fail_fast: true
default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
# - id: check-symlinks
- id: check-ast
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
exclude_types: [svg]
- id: mixed-line-ending
- id: trailing-whitespace
- id: name-tests-test
args: ["--pytest-test-first"]
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.13
hooks:
- id: validate-pyproject
name: Validate pyproject.toml
# I don't yet trust ruff to do what autoflake does
- repo: https://github.com/PyCQA/autoflake
rev: v2.1.1
hooks:
- id: autoflake
args: [--in-place]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/asottile/pyupgrade
rev: v3.6.0
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
# - id: black-jupyter
# - repo: https://github.com/charliermarsh/ruff-pre-commit
# rev: v0.0.272
# hooks:
# - id: ruff
# args: [--fix-only, --show-fixes]
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
additional_dependencies: &flake8_dependencies
# These versions need updated manually
- flake8==6.0.0
- flake8-comprehensions==3.12.0
- flake8-bugbear==23.6.5
- flake8-simplify==0.20.0
- repo: https://github.com/asottile/yesqa
rev: v1.5.0
hooks:
- id: yesqa
additional_dependencies: *flake8_dependencies
- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
hooks:
- id: codespell
types_or: [python, rst, markdown]
additional_dependencies: [tomli]
files: ^(innerscope|docs)/
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.272
hooks:
- id: ruff
# `pyroma` may help keep our package standards up to date if best practices change.
# This is probably a "low value" check though and safe to remove if we want faster pre-commit.
- repo: https://github.com/regebro/pyroma
rev: "4.2"
hooks:
- id: pyroma
args: [-n, "10", .]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: no-commit-to-branch # no commit directly to main
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
recursive-include innerscope *.py
include setup.py
include conftest.py
include README.md
include LICENSE
include MANIFEST.in
include versioneer.py
include innerscope/_version.py
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# Innerscope

[![Python Version](https://img.shields.io/badge/python-3.7%20%7C%203.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%20PyPy-blue)](https://img.shields.io/badge/python-3.7%20%7C%203.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%20PyPy-blue)
[![Version](https://img.shields.io/pypi/v/innerscope.svg)](https://pypi.org/project/innerscope/)
[![conda-forge](https://img.shields.io/conda/vn/conda-forge/innerscope.svg)](https://anaconda.org/conda-forge/innerscope)
[![pypi](https://img.shields.io/pypi/v/innerscope.svg)](https://pypi.python.org/pypi/innerscope/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/innerscope)](https://pypi.python.org/pypi/innerscope/)
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://github.com/eriknw/innerscope/blob/master/LICENSE)
[![Build Status](https://github.com/eriknw/innerscope/workflows/Test/badge.svg)](https://github.com/eriknw/innerscope/actions)
[![Coverage Status](https://coveralls.io/repos/eriknw/innerscope/badge.svg?branch=master)](https://coveralls.io/r/eriknw/innerscope)
[![Tests](https://github.com/eriknw/innerscope/workflows/Test/badge.svg?branch=main)](https://github.com/eriknw/innerscope/actions)
[![Coverage](https://coveralls.io/repos/eriknw/innerscope/badge.svg?branch=main)](https://coveralls.io/r/eriknw/innerscope)

`innerscope` exposes the inner scope of functions and offers primitives suitable for creating pipelines. It explores a design space around functions, dictionaries, and classes.

**To install with pip:**
- `pip install innerscope`
`pip install innerscope`

**To install with conda:**
- `conda install -c conda-forge innerscope`
`conda install -c conda-forge innerscope`

A function can be made to act like a dictionary:
```python
Expand Down Expand Up @@ -129,4 +131,3 @@ It's all [@mrocklin's](https://github.com/mrocklin) fault for [asking a question
I bet it would even be useful for building pipelines with dask. I'm sure there are other creative uses for it just waiting to be discovered. **Update:** and [`afar`](https://github.com/eriknw/afar) has been born!

#### *This library is totally awesome and you should use it and tell all your friends* 😉 *!*

17 changes: 13 additions & 4 deletions innerscope/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
from ._version import get_versions
from .core import bindwith, call, callwith, scoped_function # noqa
import importlib.metadata

__version__ = get_versions()["version"]
del get_versions
from .core import bindwith, call, callwith, scoped_function

try:
__version__ = importlib.metadata.version("innerscope")
except Exception as exc: # pragma: no cover (safety)
raise AttributeError(
"`innerscope.__version__` not available. This may mean "
"innerscope was incorrectly installed or not installed at all. "
"For local development, you may want to do an editable install via "
"`python -m pip install -e path/to/innerscope`"
) from exc
del importlib
Loading

0 comments on commit 4289aec

Please sign in to comment.