Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use uv #84

Merged
merged 7 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
exclude = .tox,.git,docs,dist,build,todo,.venv
ignore = E731,E221,W503,E741,E203
max-line-length = 119
60 changes: 19 additions & 41 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,25 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8, 3.9, "3.10", "3.11", "pypy-3.7"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy-3.9"]

env:
PYTHON: ${{ matrix.python-version }}

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }} with uv
uses: drivendataorg/setup-python[email protected]
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python }}-${{ hashFiles('tests/requirements-tests.txt') }}
- name: Install deps
cache: 'packages'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r tests/requirements-tests.txt
python setup.py develop --no-deps
uv sync
- name: Run tests
run: |
pytest --cov=./ --cov-report=xml
uv run pytest --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
Expand All @@ -47,35 +43,17 @@ jobs:

linters:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.9"
- uses: actions/cache@v2
- uses: actions/checkout@v4
- name: Set up Python 3.10 with uv
uses: drivendataorg/[email protected]
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('tests/requirements-linters.txt') }}
- name: Install deps
run: |
python -m pip install --upgrade pip
pip install -r tests/requirements-linters.txt
- name: Run isort
run: |
isort --version
isort -c .
- name: Run flake8
if: failure() || success()
python-version: "3.10"
cache: 'packages'

- name: Install dependencies
run: |
flake8 --version
flake8
- name: Run check-manifest
if: failure() || success()
uv sync
- name: Run pre-commit checks
run: |
check-manifest
- uses: psf/black@stable
with:
version: "22.3.0"
if: failure() || success()
uv run pre-commit run --all --all-files
15 changes: 7 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,36 @@ repos:
rev: 3.8.4
hooks:
- id: flake8
language_version: python3.9
language_version: python3.10
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.6.4
hooks:
- id: isort
language_version: python3.9
language_version: python3.10
- repo: https://github.com/ikamensh/flynt/
rev: '0.69'
hooks:
- id: flynt
language_version: python3.9
language_version: python3.10
- repo: https://github.com/asottile/pyupgrade
rev: v2.26.0
hooks:
- id: pyupgrade
entry: pyupgrade --py3-plus --py36-plus --py37-plus --keep-runtime-typing
language_version: python3.9
language_version: python3.10
- repo: https://github.com/myint/autoflake
rev: 'v1.4'
hooks:
- id: autoflake
args: ['--remove-all-unused-imports', '-i']
language_version: python3.9
language_version: python3.10
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: 'v1.5.7'
hooks:
- id: autopep8
language_version: python3.9
language_version: python3.10
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
language_version: python3
language_version: python3.9
language_version: python3.10
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
10 changes: 7 additions & 3 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
version: 2

build:
image: latest
os: "ubuntu-22.04"
tools:
python: "3.11"

python:
version: 3.8
install:
- requirements: docs/requirements.txt
- method: setuptools
- method: pip
path: .

sphinx:
configuration: docs/conf.py
47 changes: 36 additions & 11 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,38 @@ contribute by making a fork, and submitting a PR on `GitHub
We have a high standard in terms of quality. All contributions will need to be
fully covered by unit tests and documentation.

To run the test suite::
To get started you’ll need to:

- Check out the repo using git, ``cd`` into the directory.

- Set up a venv for development. We use `uv <https://docs.astral.sh/uv/>`_ and
recommend you do the same. With uv, the setup instructions are::

uv sync

This will use your default Python version. If you want to use a different
Python version, instead of the above do this e.g.::

uv python install 3.10
uv venv --python 3.10
uv sync

- Activate the venv::

source .venv/bin/activate

(Alternatively, you can add ``uv run`` before most of the commands below)

- Get test suite running::

pip install pytest
pytest

To run the test suite on all supported Python versions, and code quality checks,
first install the various Python versions, then::
- Run tests against all versions::

pip install tox
tox

To build the docs, do::
- To build the docs, do::

pip install sphinx
cd docs
make html

Expand All @@ -31,12 +49,19 @@ including `flake8 <http://flake8.pycqa.org/en/latest/>`_, `isort
<https://github.com/psf/black>`_. These are most easily add by using `pre-commit
<https://pre-commit.com/>`_:

* Install pre-commit globally e.g. ``pipx install pre-commit`` if you already
have `pipx <https://github.com/pypa/pipx>`_.
- Install `pre-commit <https://pre-commit.com/>`_ in the repo::

pre-commit install

This will add Git hooks to run linters when committing, which ensures our style
(black) and other things.

Now all the linters will run when you commit changes.

- You can also manually run these linters using::

* Do ``pre-commit install`` in the repo.
pre-commit run --all --all-files

Now all the linters will run when you commit changes.

When writing documentation, please keep in mind Daniele Procida's `great article
on documentation <https://www.divio.com/en/blog/documentation/>`_. To summarise,
Expand Down
4 changes: 4 additions & 0 deletions docs/history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ History and release notes

.. currentmodule:: parsy

2.2 - unreleased
----------------
* Dropped support for Python 3.7, 3.8 which are past EOL

2.1 - 2023-02-22
----------------

Expand Down
69 changes: 67 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,76 @@
[project]
name = "parsy"
description = "Easy-to-use parser combinators, for parsing in pure Python"
license = {text = "MIT"}
authors = [
{ name = "Jeanine Adkisson", email = "[email protected]" }
]
maintainers = [
{ name = "Luke Plant", email = "[email protected]" }
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Topic :: Software Development :: Compilers",
"Topic :: Software Development :: Interpreters",
"Topic :: Text Processing",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
keywords = ["parser", "parsers", "parsing", "monad", "combinators"]
urls = {Homepage = "https://github.com/python-parsy/parsy"}

requires-python = ">=3.9"
dependencies = []

dynamic = ["version"]

[project.readme]
file = "README.rst"
content-type = "text/x-rst"

[tool.setuptools.dynamic]
version = {attr = "parsy.__version__"}

[build-system]
requires = ["setuptools>=61.2"]
build-backend = "setuptools.build_meta"

[dependency-groups]
dev = [
"pre-commit>=4.1.0",
"pytest>=8.3.4",
"tox-uv>=1.20.1",
"tox>=4.24.1",
"pytest-cov>=6.0.0",
"pre-commit-uv>=4.1.4",
]

[tool.setuptools]
package-dir = {"" = "src"}
include-package-data = false

[tool.setuptools.packages.find]
where = ["src"]
namespaces = false

[tool.black]
line-length = 119
# required-version = '22.1.0' # see https://github.com/psf/black/issues/2493
target-version = ['py310']

[tool.isort]
line_length = 119
profile = "black"
default_section = "THIRDPARTY"
skip = [".tox", ".git", "docs", "dist", "build" , "todo"]
skip = [".tox", ".git", "docs", "dist", "build" , "todo", ".venv"]
known_first_party = "parsy"

[tool.flake8]
exclude = [".tox", ".git", "docs", "dist", "build", "todo"]
ignore = ["E731", "E221", "W503", "E741", "E203" ]
max-line-length = 119
9 changes: 5 additions & 4 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ pre-commit run --all --all-files || exit 1
umask 000
rm -rf build dist
git ls-tree --full-tree --name-only -r HEAD | xargs chmod ugo+r
python setup.py sdist || exit 1
python setup.py bdist_wheel || exit 1

VERSION=$(python setup.py --version) || exit 1
twine upload dist/parsy-$VERSION-py3-none-any.whl dist/parsy-$VERSION.tar.gz || exit 1
uv build --sdist --wheel || exit 1
uv publish || exit 1

VERSION=$(uv pip show parsy | grep 'Version: ' | cut -f 2 -d ' ' | tr -d '\n') || exit 1

git tag v$VERSION || exit 1
git push || exit 1
git push --tags || exit 1
39 changes: 0 additions & 39 deletions setup.cfg

This file was deleted.

3 changes: 0 additions & 3 deletions setup.py

This file was deleted.

1 change: 0 additions & 1 deletion tests/requirements-linters.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
isort==5.4.2
flake8==3.8.3
check-manifest
Loading
Loading