mirror of
https://github.com/enpaul/peewee-plus.git
synced 2025-10-29 15:45:16 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5520faef88 | |||
| 60bdfbfb17 | |||
| d5d400e0a6 | |||
| e98aa73a8d | |||
| 4f5e007d7d | |||
| 134c28fd92 | |||
|
|
dac554e8d4 | ||
| 44ad5da339 | |||
| ef8800059f | |||
| c6cab6ce2d | |||
| 6e9c3c2521 | |||
| 02642312fb |
34
.github/scripts/setup-env.sh
vendored
Executable file
34
.github/scripts/setup-env.sh
vendored
Executable file
@@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Environment setup script for the local project. Intended to be used with automation
|
||||||
|
# to create a repeatable local environment for tests to be run in. The python env
|
||||||
|
# this script creates can be accessed at the location defined by the CI_VENV variable
|
||||||
|
# below.
|
||||||
|
|
||||||
|
set -e;
|
||||||
|
|
||||||
|
CI_CACHE=$HOME/.cache;
|
||||||
|
POETRY_VERSION=1.2.2;
|
||||||
|
|
||||||
|
mkdir --parents "$CI_CACHE";
|
||||||
|
|
||||||
|
command -v python;
|
||||||
|
python --version;
|
||||||
|
|
||||||
|
curl --location https://install.python-poetry.org \
|
||||||
|
--output "$CI_CACHE/install-poetry.py" \
|
||||||
|
--silent \
|
||||||
|
--show-error;
|
||||||
|
python "$CI_CACHE/install-poetry.py" \
|
||||||
|
--version "$POETRY_VERSION" \
|
||||||
|
--yes;
|
||||||
|
poetry --version --no-ansi;
|
||||||
|
poetry run pip --version;
|
||||||
|
|
||||||
|
poetry install \
|
||||||
|
--quiet \
|
||||||
|
--remove-untracked \
|
||||||
|
--no-ansi;
|
||||||
|
|
||||||
|
poetry env info;
|
||||||
|
poetry run tox --version;
|
||||||
89
.github/workflows/ci.yaml
vendored
Normal file
89
.github/workflows/ci.yaml
vendored
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
---
|
||||||
|
name: CI
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: ["opened", "synchronize"]
|
||||||
|
push:
|
||||||
|
branches: ["devel"]
|
||||||
|
jobs:
|
||||||
|
Test:
|
||||||
|
name: Test with Python ${{ matrix.python.version }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python:
|
||||||
|
- version: "3.7"
|
||||||
|
toxenv: py37
|
||||||
|
- version: "3.8"
|
||||||
|
toxenv: py38
|
||||||
|
- version: "3.9"
|
||||||
|
toxenv: py39
|
||||||
|
- version: "3.10"
|
||||||
|
toxenv: py310
|
||||||
|
fail-fast: true
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install Python ${{ matrix.python.version }}
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python.version }}
|
||||||
|
|
||||||
|
- name: Configure Job Cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cache/pip
|
||||||
|
~/.cache/pypoetry/cache
|
||||||
|
~/.poetry
|
||||||
|
# Including the hashed poetry.lock in the cache slug ensures that the cache
|
||||||
|
# will be invalidated, and thus all packages will be redownloaded, if the
|
||||||
|
# lockfile is updated
|
||||||
|
key: ${{ runner.os }}-${{ matrix.python.toxenv }}-${{ hashFiles('**/poetry.lock') }}
|
||||||
|
|
||||||
|
- name: Configure Path
|
||||||
|
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
|
||||||
|
|
||||||
|
- name: Configure Environment
|
||||||
|
run: .github/scripts/setup-env.sh
|
||||||
|
|
||||||
|
- name: Run Toxenv ${{ matrix.python.toxenv }}
|
||||||
|
run: poetry run tox -e ${{ matrix.python.toxenv }}
|
||||||
|
Check:
|
||||||
|
name: Security, Linting, Formatting, Typing
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install Python 3.10
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: "3.10"
|
||||||
|
|
||||||
|
- name: Configure Job Cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cache/pip
|
||||||
|
~/.cache/pypoetry/cache
|
||||||
|
~/.poetry
|
||||||
|
# Hardcoded 'py310' slug here lets this cache piggyback on the 'py310' cache
|
||||||
|
# that is generated for the tests above
|
||||||
|
key: ${{ runner.os }}-py310-${{ hashFiles('**/poetry.lock') }}
|
||||||
|
|
||||||
|
- name: Configure Path
|
||||||
|
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
|
||||||
|
|
||||||
|
- name: Configure Environment
|
||||||
|
run: .github/scripts/setup-env.sh
|
||||||
|
|
||||||
|
- name: Run Static Analysis Checks
|
||||||
|
run: poetry run tox -e static
|
||||||
|
|
||||||
|
- name: Run Static Analysis Checks (Tests)
|
||||||
|
run: poetry run tox -e static-tests
|
||||||
|
|
||||||
|
- name: Run Security Checks
|
||||||
|
run: poetry run tox -e security
|
||||||
@@ -2,6 +2,15 @@
|
|||||||
|
|
||||||
See also: [Github Release Page](https://github.com/enpaul/peewee-plus/releases).
|
See also: [Github Release Page](https://github.com/enpaul/peewee-plus/releases).
|
||||||
|
|
||||||
|
## Version 1.2.0
|
||||||
|
|
||||||
|
View this release on: [Github](https://github.com/enpaul/peewee-plus/releases/tag/1.2.0),
|
||||||
|
[PyPI](https://pypi.org/project/peewee-plus/1.2.0/)
|
||||||
|
|
||||||
|
- Remove support for Python 3.6
|
||||||
|
- Update development workflows to use Poetry 1.2
|
||||||
|
- Fix nullable enums raising an `IntegrityError` when value is `None` (#1)
|
||||||
|
|
||||||
## Version 1.1.0
|
## Version 1.1.0
|
||||||
|
|
||||||
View this release on: [Github](https://github.com/enpaul/peewee-plus/releases/tag/1.1.0),
|
View this release on: [Github](https://github.com/enpaul/peewee-plus/releases/tag/1.1.0),
|
||||||
|
|||||||
4
Makefile
4
Makefile
@@ -33,11 +33,11 @@ source: ## Build Python source distribution package
|
|||||||
build: clean wheel source; ## Build all distribution packages
|
build: clean wheel source; ## Build all distribution packages
|
||||||
|
|
||||||
test: clean-tox ## Run the project testsuite(s)
|
test: clean-tox ## Run the project testsuite(s)
|
||||||
poetry run tox
|
poetry run tox --parallel
|
||||||
|
|
||||||
publish: clean test build ## Build and upload to pypi (requires $PYPI_API_KEY be set)
|
publish: clean test build ## Build and upload to pypi (requires $PYPI_API_KEY be set)
|
||||||
@poetry publish --username __token__ --password $(PYPI_API_KEY)
|
@poetry publish --username __token__ --password $(PYPI_API_KEY)
|
||||||
|
|
||||||
dev: ## Create local dev environment
|
dev: ## Create local dev environment
|
||||||
poetry install --remove-untracked
|
poetry install --sync
|
||||||
poetry run pre-commit install
|
poetry run pre-commit install
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
Various extensions, helpers, and utilities for [Peewee](http://peewee-orm.com)
|
Various extensions, helpers, and utilities for [Peewee](http://peewee-orm.com)
|
||||||
|
|
||||||
|
[](https://github.com/enpaul/peewee-plus/actions)
|
||||||
[](https://pypi.org/project/peewee-plus/)
|
[](https://pypi.org/project/peewee-plus/)
|
||||||
|
[](https://libraries.io/pypi/peewee-plus)
|
||||||
[](https://opensource.org/licenses/MIT)
|
[](https://opensource.org/licenses/MIT)
|
||||||
[](https://www.python.org)
|
[](https://www.python.org)
|
||||||
[](https://github.com/psf/black)
|
[](https://github.com/psf/black)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import peewee
|
|||||||
|
|
||||||
|
|
||||||
__title__ = "peewee-plus"
|
__title__ = "peewee-plus"
|
||||||
__version__ = "1.1.0"
|
__version__ = "1.2.0"
|
||||||
__license__ = "MIT"
|
__license__ = "MIT"
|
||||||
__summary__ = "Various extensions, helpers, and utilities for Peewee"
|
__summary__ = "Various extensions, helpers, and utilities for Peewee"
|
||||||
__url__ = "https://github.com/enpaul/peewee-plus/"
|
__url__ = "https://github.com/enpaul/peewee-plus/"
|
||||||
@@ -176,7 +176,10 @@ def flat_transaction(interface: peewee.Database):
|
|||||||
return outer
|
return outer
|
||||||
|
|
||||||
|
|
||||||
class PathField(peewee.CharField):
|
# TODO: The disable=abstract-method pragmas below are to get around new linting warnings
|
||||||
|
# in pylint>2.12, but they haven't been addressed properly. They should be revisited
|
||||||
|
# and fixed properly in the future.
|
||||||
|
class PathField(peewee.CharField): # pylint: disable=abstract-method
|
||||||
"""Field class for storing file paths
|
"""Field class for storing file paths
|
||||||
|
|
||||||
This field can be used to simply store pathlib paths in the database without needing to
|
This field can be used to simply store pathlib paths in the database without needing to
|
||||||
@@ -234,7 +237,7 @@ class PathField(peewee.CharField):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class PrecisionFloatField(peewee.FloatField):
|
class PrecisionFloatField(peewee.FloatField): # pylint: disable=abstract-method
|
||||||
"""Field class for storing floats with custom precision parameters
|
"""Field class for storing floats with custom precision parameters
|
||||||
|
|
||||||
This field adds support for specifying the ``M`` and ``D`` precision parameters of a
|
This field adds support for specifying the ``M`` and ``D`` precision parameters of a
|
||||||
@@ -264,7 +267,7 @@ class PrecisionFloatField(peewee.FloatField):
|
|||||||
return [self.max_digits, self.decimal_places]
|
return [self.max_digits, self.decimal_places]
|
||||||
|
|
||||||
|
|
||||||
class JSONField(peewee.TextField):
|
class JSONField(peewee.TextField): # pylint: disable=abstract-method
|
||||||
"""Field class for storing JSON-serializable data
|
"""Field class for storing JSON-serializable data
|
||||||
|
|
||||||
This field can be used to store a dictionary of data directly in the database without needing
|
This field can be used to store a dictionary of data directly in the database without needing
|
||||||
@@ -319,7 +322,7 @@ class JSONField(peewee.TextField):
|
|||||||
) from err
|
) from err
|
||||||
|
|
||||||
|
|
||||||
class EnumField(peewee.CharField):
|
class EnumField(peewee.CharField): # pylint: disable=abstract-method
|
||||||
"""Field class for storing Enums
|
"""Field class for storing Enums
|
||||||
|
|
||||||
This field can be used for storing members of an :class:`enum.Enum` in the database,
|
This field can be used for storing members of an :class:`enum.Enum` in the database,
|
||||||
@@ -364,7 +367,11 @@ class EnumField(peewee.CharField):
|
|||||||
|
|
||||||
def python_value(self, value: str) -> enum.Enum:
|
def python_value(self, value: str) -> enum.Enum:
|
||||||
try:
|
try:
|
||||||
return self.enumeration[super().python_value(value)]
|
return (
|
||||||
|
None
|
||||||
|
if value is None and self.null
|
||||||
|
else self.enumeration[super().python_value(value)]
|
||||||
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise peewee.IntegrityError(
|
raise peewee.IntegrityError(
|
||||||
f"Enum {self.enumeration.__name__} has no value with name '{value}'"
|
f"Enum {self.enumeration.__name__} has no value with name '{value}'"
|
||||||
|
|||||||
1712
poetry.lock
generated
1712
poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "peewee-plus"
|
name = "peewee-plus"
|
||||||
version = "1.1.0"
|
version = "1.2.0"
|
||||||
description = "Various extensions, helpers, and utilities for Peewee"
|
description = "Various extensions, helpers, and utilities for Peewee"
|
||||||
authors = ["Ethan Paul <24588726+enpaul@users.noreply.github.com>"]
|
authors = ["Ethan Paul <24588726+enpaul@users.noreply.github.com>"]
|
||||||
repository = "https://github.com/enpaul/peewee-plus/"
|
repository = "https://github.com/enpaul/peewee-plus/"
|
||||||
@@ -17,7 +17,6 @@ classifiers = [
|
|||||||
"Intended Audience :: Developers",
|
"Intended Audience :: Developers",
|
||||||
"License :: OSI Approved :: MIT License",
|
"License :: OSI Approved :: MIT License",
|
||||||
"Programming Language :: Python :: 3",
|
"Programming Language :: Python :: 3",
|
||||||
"Programming Language :: Python :: 3.6",
|
|
||||||
"Programming Language :: Python :: 3.7",
|
"Programming Language :: Python :: 3.7",
|
||||||
"Programming Language :: Python :: 3.8",
|
"Programming Language :: Python :: 3.8",
|
||||||
"Programming Language :: Python :: 3.9",
|
"Programming Language :: Python :: 3.9",
|
||||||
@@ -28,29 +27,29 @@ classifiers = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.6.1"
|
python = "^3.7.1"
|
||||||
peewee = "^3.14.8"
|
peewee = "^3.14.8"
|
||||||
|
|
||||||
[tool.poetry.dev-dependencies]
|
[tool.poetry.dev-dependencies]
|
||||||
bandit = "^1.7.1"
|
bandit = "^1.7.1"
|
||||||
black = {version = "^21.11b1", python = "^3.7"}
|
black = "^22.8.0"
|
||||||
blacken-docs = {version = "^1.12.0", python = "^3.7"}
|
blacken-docs = "^1.12.0"
|
||||||
ipython = {version = "^7.29.0", python = "^3.7"}
|
ipython = "^7.29.0"
|
||||||
mdformat = "^0.6.4"
|
mdformat = "^0.6.4"
|
||||||
mdformat-gfm = "^0.2"
|
mdformat-gfm = "^0.2"
|
||||||
mypy = "^0.910"
|
mypy = "^0.910"
|
||||||
pre-commit = "^2.15.0"
|
pre-commit = "^2.15.0"
|
||||||
pre-commit-hooks = "^4.0.1"
|
pre-commit-hooks = "^4.0.1"
|
||||||
pylint = "^2.11.1"
|
pylint = "^2.13.0"
|
||||||
pytest = "^6.2.5"
|
pytest = "^6.2.5"
|
||||||
pytest-cov = "^3.0.0"
|
pytest-cov = "^3.0.0"
|
||||||
reorder-python-imports = "^2.6.0"
|
reorder-python-imports = "^2.6.0"
|
||||||
safety = "^1.10.3"
|
safety = "^2.2.0"
|
||||||
toml = "^0.10.2"
|
toml = "^0.10.2"
|
||||||
tox = "^3.24.4"
|
tox = "^3.24.4"
|
||||||
tox-poetry-installer = {extras = ["poetry"], version = "^0.8.2"}
|
tox-poetry-installer = {extras = ["poetry"], version = "^0.10.0"}
|
||||||
types-toml = "^0.10.1"
|
types-toml = "^0.10.1"
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["poetry-core>=1.0.0"]
|
requires = ["poetry-core>=1.1.0"]
|
||||||
build-backend = "poetry.core.masonry.api"
|
build-backend = "poetry.core.masonry.api"
|
||||||
|
|||||||
8
tox.ini
8
tox.ini
@@ -1,6 +1,6 @@
|
|||||||
[tox]
|
[tox]
|
||||||
envlist =
|
envlist =
|
||||||
py{36,37,38,39,310}
|
py{37,38,39,310}
|
||||||
static
|
static
|
||||||
static-tests
|
static-tests
|
||||||
security
|
security
|
||||||
@@ -24,7 +24,7 @@ commands =
|
|||||||
|
|
||||||
[testenv:static]
|
[testenv:static]
|
||||||
description = Static formatting and quality enforcement
|
description = Static formatting and quality enforcement
|
||||||
basepython = python3.8
|
basepython = python3.10
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
locked_deps =
|
locked_deps =
|
||||||
black
|
black
|
||||||
@@ -47,7 +47,7 @@ commands =
|
|||||||
|
|
||||||
[testenv:static-tests]
|
[testenv:static-tests]
|
||||||
description = Static formatting and quality enforcement for the tests
|
description = Static formatting and quality enforcement for the tests
|
||||||
basepython = python3.8
|
basepython = python3.10
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
locked_deps =
|
locked_deps =
|
||||||
mypy
|
mypy
|
||||||
@@ -63,7 +63,7 @@ commands =
|
|||||||
|
|
||||||
[testenv:security]
|
[testenv:security]
|
||||||
description = Security checks
|
description = Security checks
|
||||||
basepython = python3.8
|
basepython = python3.10
|
||||||
skip_install = true
|
skip_install = true
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
locked_deps =
|
locked_deps =
|
||||||
|
|||||||
Reference in New Issue
Block a user