Skip to content

Commit 4289aec

Browse files
authored
Merge pull request #19 from eriknw/pyproject_toml
Modernize to use pyproject.toml and pre-commit
2 parents 41a7bfe + b168b3b commit 4289aec

File tree

18 files changed

+416
-2597
lines changed

18 files changed

+416
-2597
lines changed

.flake8

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[flake8]
2+
max-line-length = 100
3+
inline-quotes = "
4+
exclude =
5+
build/
6+
extend-ignore =
7+
E203,
8+
SIM105,
9+
SIM401,
10+
# E203 whitespace before ':' (to be compatible with black)
11+
per-file-ignores =
12+
__init__.py:F401
13+
innerscope/tests/test_repr.py:E501,F821,F841
14+
innerscope/tests/*.py:C408,C416,T201,E702,E703,F821,F841,W606

.gitattributes

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/lint.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Rely on pre-commit.ci
2+
name: Lint via pre-commit
3+
4+
on:
5+
workflow_dispatch:
6+
# pull_request:
7+
# push:
8+
# branches-ignore:
9+
# - main
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
pre-commit:
16+
name: pre-commit-hooks
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
- uses: actions/setup-python@v4
21+
with:
22+
python-version: "3.10"
23+
- uses: pre-commit/action@v3.0.0

.github/workflows/pypi.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ jobs:
99
build_and_deploy:
1010
runs-on: ubuntu-latest
1111
if: github.repository == 'eriknw/innerscope'
12-
defaults:
13-
run:
14-
shell: bash -l {0}
1512
steps:
1613
- name: Checkout
1714
uses: actions/checkout@v3
@@ -24,7 +21,7 @@ jobs:
2421
- name: Install build dependencies
2522
run: |
2623
python -m pip install --upgrade pip
27-
python -m pip install build setuptools twine
24+
python -m pip install build twine
2825
- name: Build wheel and sdist
2926
run: python -m build --sdist --wheel
3027
- uses: actions/upload-artifact@v3

.github/workflows/test.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
15-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "pypy-3.7", "pypy-3.8", "pypy-3.9"]
15+
python-version: ["3.8", "3.9", "3.10", "3.11", "pypy-3.8", "pypy-3.9"]
1616
steps:
1717
- name: Checkout
1818
uses: actions/checkout@v3
@@ -24,20 +24,14 @@ jobs:
2424
python-version: ${{ matrix.python-version }}
2525
- name: Install dependencies
2626
run: |
27-
python -m pip install --upgrade pip setuptools wheel
27+
python -m pip install --upgrade pip
2828
pip install toolz pytest coverage
29-
pip install -e .
29+
pip install -e . --no-deps
3030
- name: PyTest
3131
run: |
3232
coverage run --branch -m pytest --doctest-modules --method bytecode
3333
coverage run -a --branch -m pytest --doctest-modules --method trace
3434
pytest --doctest-modules --method trace
35-
- name: Style checks
36-
if: (! contains(matrix.python-version, 'pypy'))
37-
run: |
38-
pip install black flake8
39-
flake8 .
40-
black innerscope *.py --check --diff
4135
- name: Coverage
4236
if: (! contains(matrix.python-version, 'pypy'))
4337
env:
@@ -51,10 +45,11 @@ jobs:
5145
5246
finish:
5347
needs: test
48+
if: always()
5449
runs-on: ubuntu-latest
5550
steps:
5651
- name: Coveralls Finished
57-
uses: coverallsapp/github-action@master
52+
uses: coverallsapp/github-action@v2
5853
with:
5954
github-token: ${{ secrets.github_token }}
6055
parallel-finished: true

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ __pycache__/
99
# Vi
1010
*.swp
1111
*.swo
12+
*.swn
1213

1314
# Distribution / packaging
1415
.Python
@@ -115,3 +116,9 @@ venv.bak/
115116

116117
# VSCode
117118
.vscode
119+
120+
# Generated IPython notebooks
121+
*.nbconvert.ipynb
122+
123+
# Dask worker
124+
dask-worker-space/

.pre-commit-config.yaml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# https://pre-commit.com/
2+
#
3+
# Before first use: `pre-commit install`
4+
# To run: `pre-commit run --all-files`
5+
# To update: `pre-commit autoupdate`
6+
# - &flake8_dependencies below needs updated manually
7+
#
8+
# Be careful about linting that rewrites code syntax we want to test.
9+
ci:
10+
# See: https://pre-commit.ci/#configuration
11+
autofix_prs: false
12+
autoupdate_schedule: quarterly
13+
skip: [no-commit-to-branch]
14+
fail_fast: true
15+
default_language_version:
16+
python: python3
17+
repos:
18+
- repo: https://github.com/pre-commit/pre-commit-hooks
19+
rev: v4.4.0
20+
hooks:
21+
- id: check-added-large-files
22+
- id: check-case-conflict
23+
- id: check-merge-conflict
24+
# - id: check-symlinks
25+
- id: check-ast
26+
- id: check-toml
27+
- id: check-yaml
28+
- id: debug-statements
29+
- id: end-of-file-fixer
30+
exclude_types: [svg]
31+
- id: mixed-line-ending
32+
- id: trailing-whitespace
33+
- id: name-tests-test
34+
args: ["--pytest-test-first"]
35+
- repo: https://github.com/abravalheri/validate-pyproject
36+
rev: v0.13
37+
hooks:
38+
- id: validate-pyproject
39+
name: Validate pyproject.toml
40+
# I don't yet trust ruff to do what autoflake does
41+
- repo: https://github.com/PyCQA/autoflake
42+
rev: v2.1.1
43+
hooks:
44+
- id: autoflake
45+
args: [--in-place]
46+
- repo: https://github.com/pycqa/isort
47+
rev: 5.12.0
48+
hooks:
49+
- id: isort
50+
- repo: https://github.com/asottile/pyupgrade
51+
rev: v3.6.0
52+
hooks:
53+
- id: pyupgrade
54+
args: [--py38-plus]
55+
- repo: https://github.com/psf/black
56+
rev: 23.3.0
57+
hooks:
58+
- id: black
59+
# - id: black-jupyter
60+
# - repo: https://github.com/charliermarsh/ruff-pre-commit
61+
# rev: v0.0.272
62+
# hooks:
63+
# - id: ruff
64+
# args: [--fix-only, --show-fixes]
65+
- repo: https://github.com/PyCQA/flake8
66+
rev: 6.0.0
67+
hooks:
68+
- id: flake8
69+
additional_dependencies: &flake8_dependencies
70+
# These versions need updated manually
71+
- flake8==6.0.0
72+
- flake8-comprehensions==3.12.0
73+
- flake8-bugbear==23.6.5
74+
- flake8-simplify==0.20.0
75+
- repo: https://github.com/asottile/yesqa
76+
rev: v1.5.0
77+
hooks:
78+
- id: yesqa
79+
additional_dependencies: *flake8_dependencies
80+
- repo: https://github.com/codespell-project/codespell
81+
rev: v2.2.4
82+
hooks:
83+
- id: codespell
84+
types_or: [python, rst, markdown]
85+
additional_dependencies: [tomli]
86+
files: ^(innerscope|docs)/
87+
- repo: https://github.com/charliermarsh/ruff-pre-commit
88+
rev: v0.0.272
89+
hooks:
90+
- id: ruff
91+
# `pyroma` may help keep our package standards up to date if best practices change.
92+
# This is probably a "low value" check though and safe to remove if we want faster pre-commit.
93+
- repo: https://github.com/regebro/pyroma
94+
rev: "4.2"
95+
hooks:
96+
- id: pyroma
97+
args: [-n, "10", .]
98+
- repo: https://github.com/pre-commit/pre-commit-hooks
99+
rev: v4.4.0
100+
hooks:
101+
- id: no-commit-to-branch # no commit directly to main

MANIFEST.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
recursive-include innerscope *.py
12
include setup.py
3+
include conftest.py
24
include README.md
35
include LICENSE
46
include MANIFEST.in
5-
include versioneer.py
6-
include innerscope/_version.py

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
# Innerscope
22

3-
[![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)
4-
[![Version](https://img.shields.io/pypi/v/innerscope.svg)](https://pypi.org/project/innerscope/)
3+
[![conda-forge](https://img.shields.io/conda/vn/conda-forge/innerscope.svg)](https://anaconda.org/conda-forge/innerscope)
4+
[![pypi](https://img.shields.io/pypi/v/innerscope.svg)](https://pypi.python.org/pypi/innerscope/)
5+
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/innerscope)](https://pypi.python.org/pypi/innerscope/)
56
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://github.com/eriknw/innerscope/blob/master/LICENSE)
6-
[![Build Status](https://github.com/eriknw/innerscope/workflows/Test/badge.svg)](https://github.com/eriknw/innerscope/actions)
7-
[![Coverage Status](https://coveralls.io/repos/eriknw/innerscope/badge.svg?branch=master)](https://coveralls.io/r/eriknw/innerscope)
7+
[![Tests](https://github.com/eriknw/innerscope/workflows/Test/badge.svg?branch=main)](https://github.com/eriknw/innerscope/actions)
8+
[![Coverage](https://coveralls.io/repos/eriknw/innerscope/badge.svg?branch=main)](https://coveralls.io/r/eriknw/innerscope)
89

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

1112
**To install with pip:**
12-
- `pip install innerscope`
13+
`pip install innerscope`
14+
1315
**To install with conda:**
14-
- `conda install -c conda-forge innerscope`
16+
`conda install -c conda-forge innerscope`
1517

1618
A function can be made to act like a dictionary:
1719
```python
@@ -129,4 +131,3 @@ It's all [@mrocklin's](https://github.com/mrocklin) fault for [asking a question
129131
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!
130132

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

innerscope/__init__.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1-
from ._version import get_versions
2-
from .core import bindwith, call, callwith, scoped_function # noqa
1+
import importlib.metadata
32

4-
__version__ = get_versions()["version"]
5-
del get_versions
3+
from .core import bindwith, call, callwith, scoped_function
4+
5+
try:
6+
__version__ = importlib.metadata.version("innerscope")
7+
except Exception as exc: # pragma: no cover (safety)
8+
raise AttributeError(
9+
"`innerscope.__version__` not available. This may mean "
10+
"innerscope was incorrectly installed or not installed at all. "
11+
"For local development, you may want to do an editable install via "
12+
"`python -m pip install -e path/to/innerscope`"
13+
) from exc
14+
del importlib

0 commit comments

Comments
 (0)