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

chore: modernize py3 versions #21

Merged
merged 6 commits into from
Apr 25, 2024
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
74 changes: 74 additions & 0 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Build and test

on:
# Build only on pushes to main or one of the release branches
push:
branches:
- main
tags:
# Build pull requests
pull_request:

jobs:
test:
strategy:
matrix:
py:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "pypy-3.10"
os:
- "ubuntu-latest"
architecture:
- x64
include:
# Only run coverage on ubuntu-latest, except on pypy3
- os: "ubuntu-latest"
pytest-args: "--cov"
- os: "ubuntu-latest"
py: "pypy-3.7"
pytest-args: ""
name: "Python: ${{ matrix.py }}-${{ matrix.architecture }} on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.py }}
architecture: ${{ matrix.architecture }}
- run: pip install --upgrade setuptools pip
- run: pip install tox
- name: Running tox
run: tox -e py -- ${{ matrix.pytest-args }}
coverage:
runs-on: ubuntu-latest
name: Validate coverage
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: 3.12
architecture: x64
- run: pip install --upgrade setuptools pip
- run: |
pip install tox
tox -e py312-cover,coverage
docs:
runs-on: ubuntu-latest
name: Build the documentation
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: 3.12
architecture: x64
- run: pip install --upgrade setuptools pip
- run: |
pip install tox
tox -e docs
18 changes: 18 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
Changes
=======

0.7 (unreleased)
----------------

- Add Github workflow CI.

- Update distribution packaging (``pyproject.toml``).

- Update test runner to ``pytest``.

- Refactor tests using ``pytest`` patterns.

- Add support for Python 3.8, 3.9, 3.10, 3.11 and 3.12.

- Drop support for 2.7, 3.4, 3.5, 3.6 and 3.7.

- Remove the ``pytest.compat`` module.


0.6 (2018-08-24)
----------------

Expand Down
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# out serve to show the default value.

import datetime
import pkg_resources
from importlib import metadata
import pylons_sphinx_themes


Expand All @@ -36,7 +36,7 @@

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc']
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest']

# Add any paths that contain templates here, relative to this directory.
templates_path = ['.templates']
Expand All @@ -57,7 +57,7 @@
# other places throughout the built documents.
#
# The short X.Y version.
version = pkg_resources.get_distribution('peppercorn').version
version = metadata.version('peppercorn')
# The full version, including alpha/beta/rc tags.
release = version

Expand Down
35 changes: 27 additions & 8 deletions peppercorn/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@

def data_type(value):
if ':' in value:
return [ x.strip() for x in value.rsplit(':', 1) ]
return ('', value.strip())

START = '__start__'
END = '__end__'
SEQUENCE = 'sequence'
Expand All @@ -13,6 +8,30 @@ def data_type(value):
TYPS = (SEQUENCE, MAPPING, RENAME, IGNORE)


def data_type(value):
if ':' in value:
return [ x.strip() for x in value.rsplit(':', 1) ]
return ('', value.strip())


class UnknownStartMarker(ValueError):
def __init__(self, token):
self.token = token
super().__init__(
f"Unknown start marker {repr(token)}"
)


class TooManyEndMarkers(ValueError):
def __init__(self):
super().__init__("Too many end markers")


class NotEnoughEndMarkers(ValueError):
def __init__(self):
super().__init__("Not enough end markers")


def parse(tokens):
""" Infer a data structure from the ordered set of fields and
return it."""
Expand All @@ -28,7 +47,7 @@ def parse(tokens):
if typ in TYPS:
out = []
else:
raise ValueError("Unknown start marker %s" % repr(token))
raise UnknownStartMarker(token)
elif key == END:
if typ == SEQUENCE:
parsed = [v for (k, v) in out]
Expand All @@ -39,7 +58,7 @@ def parse(tokens):
elif typ == IGNORE:
parsed = None
else:
raise ValueError("Too many end markers")
raise TooManyEndMarkers()
prev_target, prev_typ, out = stack.pop()
if parsed is not None:
out.append((target, parsed))
Expand All @@ -49,6 +68,6 @@ def parse(tokens):
out.append(token)

if stack:
raise ValueError("Not enough end markers")
raise NotEnoughEndMarkers()

return dict(out)
10 changes: 0 additions & 10 deletions peppercorn/compat.py

This file was deleted.

Loading
Loading