Skip to content

Commit

Permalink
Various dev chores (#182)
Browse files Browse the repository at this point in the history
* Various dev chores

- Migrate to GHA
- Migrate to Ruff
- Migrate to pyproject.toml
- Publish types; add mypy

* Update badges

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Lint fixes

* Fix for py38

* ignores

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
sloria and pre-commit-ci[bot] authored Jan 17, 2024
1 parent f646dce commit 2438bc0
Show file tree
Hide file tree
Showing 17 changed files with 151 additions and 120 deletions.
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
open_collective: "marshmallow"
tidelift: "pypi/marshmallow"
56 changes: 56 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: build
on:
push:
branches: ["main", "*.x-line"]
tags: ["*"]
pull_request:

jobs:
tests:
name: ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- { name: "3.8", python: "3.8", tox: py38 }
- { name: "3.12", python: "3.12", tox: py312 }
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: ${{ matrix.python }}
allow-prereleases: true
- run: python -m pip install --upgrade pip
- run: python -m pip install tox
- run: python -m tox -e ${{ matrix.tox }}
# this duplicates pre-commit.ci, so only run it on tags
# it guarantees that linting is passing prior to a release
lint-pre-release:
name: lint
if: startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: "3.11"
- run: python -m pip install --upgrade pip
- run: python -m pip install tox
- run: python -m tox -e lint
release:
needs: [tests, lint-pre-release]
name: PyPI release
if: startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
- name: install requirements
run: python -m pip install build twine
- name: build dists
run: python -m build
- name: check package metadata
run: twine check dist/*
- name: publish
run: twine upload -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} dist/*
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ nosetests.xml
coverage.xml
*,cover
.pytest_cache/
.mypy_cache
.ruff_cache
29 changes: 14 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.11.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.13
hooks:
- id: pyupgrade
args: [--py36-plus]
- repo: https://github.com/python/black
rev: 20.8b1
- id: ruff
- id: ruff-format
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.3
hooks:
- id: black
language_version: python3
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.0
hooks:
- id: flake8
additional_dependencies: [flake8-bugbear==21.4.3]
- id: check-github-workflows
- repo: https://github.com/asottile/blacken-docs
rev: v1.10.0
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies: [black==20.8b1]
additional_dependencies: [black==23.12.1]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
additional_dependencies: ["marshmallow>=3,<4"]
11 changes: 11 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
Changelog
---------

3.1.0 (unreleased)
++++++++++++++++++

Features:

- Publish type information.

Support:

- Support Python 3.8-3.12. Older versions are no longer supported.

3.0.2 (2021-11-14)
++++++++++++++++++

Expand Down
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Copyright 2016-2017 Maxim Kulkin
Copyright 2018 Alex Rothberg and contributors
Copyright 2024 Steven Loria and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
marshmallow-oneofschema
=======================

.. image:: https://dev.azure.com/sloria/sloria/_apis/build/status/marshmallow-code.marshmallow-oneofschema?branchName=master
:target: https://dev.azure.com/sloria/sloria/_build/latest?definitionId=13&branchName=master
.. image:: https://github.com/marshmallow-code/marshmallow-oneofschema/actions/workflows/build-release.yml/badge.svg
:target: https://github.com/marshmallow-code/flask-marshmallow/actions/workflows/build-release.yml
:alt: Build Status

.. image:: https://badgen.net/badge/marshmallow/3
Expand Down
25 changes: 0 additions & 25 deletions azure-pipelines.yml

This file was deleted.

52 changes: 52 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[project]
name = "marshmallow-oneofschema"
version = "3.0.2"
description = "marshmallow multiplexing schema"
readme = "README.rst"
license = { file = "LICENSE" }
authors = [{ name = "Maxim Kulkin", email = "[email protected]" }]
maintainers = [{ name = "Steven Loria", email = "[email protected]" }]
classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
requires-python = ">=3.8"
dependencies = ["marshmallow>=3.0.0,<4.0.0"]

[project.urls]
Issues = "https://github.com/marshmallow-code/marshmallow-oneofschema/issues"
Funding = "https://opencollective.com/marshmallow"
Source = "https://github.com/marshmallow-code/marshmallow-oneofschema"

[project.optional-dependencies]
tests = ["pytest"]
dev = ["marshmallow-oneofschema[tests]", "tox", "pre-commit~=3.5"]

[build-system]
requires = ["flit_core<4"]
build-backend = "flit_core.buildapi"

[tool.flit.sdist]
include = ["tests/", "CHANGELOG.rst", "SECURITY.md", "tox.ini"]

[tool.ruff]
src = ["src"]
fix = true
show-fixes = true
show-source = true

[tool.ruff.lint]
select = [
"B", # flake8-bugbear
"E", # pycodestyle error
"F", # pyflakes
"I", # isort
"UP", # pyupgrade
"W", # pycodestyle warning
]
8 changes: 0 additions & 8 deletions setup.cfg

This file was deleted.

52 changes: 0 additions & 52 deletions setup.py

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import typing

from marshmallow import Schema, ValidationError


Expand Down Expand Up @@ -57,7 +59,7 @@ def get_obj_type(self, obj):

type_field = "type"
type_field_remove = True
type_schemas = {}
type_schemas: typing.Dict[str, typing.Type[Schema]] = {}

def get_obj_type(self, obj):
"""Returns name of the schema during dump() calls, given the object
Expand Down Expand Up @@ -167,9 +169,11 @@ def _load(self, data, *, partial=None, unknown=None, **kwargs):

try:
type_schema = self.type_schemas.get(data_type)
except TypeError:
except TypeError as error:
# data_type could be unhashable
raise ValidationError({self.type_field: ["Invalid value: %s" % data_type]})
raise ValidationError(
{self.type_field: ["Invalid value: %s" % data_type]}
) from error
if not type_schema:
raise ValidationError(
{self.type_field: ["Unsupported value: %s" % data_type]}
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion tests/test_one_of_schema.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import marshmallow as m
import marshmallow.fields as f
from marshmallow_oneofschema import OneOfSchema
import pytest

from marshmallow_oneofschema import OneOfSchema

REQUIRED_ERROR = "Missing data for required field."

Expand Down
16 changes: 3 additions & 13 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
[tox]
envlist=
lint
check-build
py{36,37,38,39}
py{38,39,310,311,312}

[testenv]
extras = tests
commands = pytest {posargs}

[testenv:lint]
deps = pre-commit~=2.7
deps = pre-commit~=3.5
skip_install = true
commands = pre-commit run --all-files --show-diff-on-failure

[testenv:check-build]
skip_install = true
deps =
twine
pip >= 18.0.0
commands =
pip wheel -w {envtmpdir}/build --no-deps .
twine check {envtmpdir}/build/*
commands = pre-commit run --all-files

; Below tasks are for development only (not run in CI)

Expand Down

0 comments on commit 2438bc0

Please sign in to comment.