Skip to content

Commit

Permalink
Add Django 5.0 to build matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
hugorodgerbrown committed Nov 15, 2023
1 parent 7249685 commit 814b0fe
Show file tree
Hide file tree
Showing 14 changed files with 157 additions and 172 deletions.
38 changes: 0 additions & 38 deletions .flake8

This file was deleted.

143 changes: 91 additions & 52 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,97 @@
name: Python / Django

on:
push:
branches:
- master
push:
branches:
- master

pull_request:
types: [opened, synchronize, reopened]
pull_request:
types: [opened, synchronize, reopened]

jobs:
format:
name: Check formatting
runs-on: ubuntu-latest
strategy:
matrix:
toxenv: [fmt, lint, mypy]
env:
TOXENV: ${{ matrix.toxenv }}

steps:
- name: Check out the repository
uses: actions/checkout@v2

- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install and run tox
run: |
pip install tox
tox
test:
name: Run tests
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.8", "3.10", "3.11"]
django: ["32", "41", main]

env:
TOXENV: py${{ matrix.python }}-django${{ matrix.django }}

steps:
- name: Check out the repository
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Install and run tox
run: |
pip install tox
tox
format:
name: Check formatting
runs-on: ubuntu-latest
strategy:
matrix:
toxenv: [fmt, lint, mypy]
env:
TOXENV: ${{ matrix.toxenv }}

steps:
- name: Check out the repository
uses: actions/checkout@v4

- name: Set up Python (3.11)
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install and run tox
run: |
pip install tox
tox
checks:
name: Run Django checks
runs-on: ubuntu-latest
strategy:
matrix:
toxenv: ["django-checks"]
env:
TOXENV: ${{ matrix.toxenv }}

steps:
- name: Check out the repository
uses: actions/checkout@v4

- name: Set up Python (3.11)
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install and run tox
run: |
pip install tox
tox
test:
name: Run tests
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
# build LTS version, next version, HEAD
django: ["32", "42", "50", "main"]
exclude:
- python: "3.8"
django: "50"
- python: "3.8"
django: "main"
- python: "3.9"
django: "50"
- python: "3.9"
django: "main"
- python: "3.10"
django: "main"
- python: "3.11"
django: "32"
- python: "3.12"
django: "32"

env:
TOXENV: django${{ matrix.django }}-py${{ matrix.python }}

steps:
- name: Check out the repository
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Install and run tox
run: |
pip install tox
tox
8 changes: 0 additions & 8 deletions .isort.cfg

This file was deleted.

33 changes: 7 additions & 26 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,45 +1,26 @@
repos:
# python import sorting - will amend files
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
hooks:
- id: isort

# python code formatting - will amend files
- repo: https://github.com/ambv/black
rev: 22.10.0
rev: 23.10.1
hooks:
- id: black

- repo: https://github.com/asottile/pyupgrade
rev: v3.1.0
hooks:
- id: pyupgrade

# Flake8 includes pyflakes, pycodestyle, mccabe, pydocstyle, bandit
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: "v0.1.5"
hooks:
- id: flake8
additional_dependencies:
- flake8-bandit
- flake8-blind-except
- flake8-docstrings
- flake8-logging-format
- flake8-print
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

# python static type checking
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.982
rev: v1.7.0
hooks:
- id: mypy
additional_dependencies:
- types-geoip2
args:
- --disallow-untyped-defs
- --disallow-incomplete-defs
- --check-untyped-defs
- --no-implicit-optional
- --ignore-missing-imports
- --follow-imports=silent
exclude: ^tests
9 changes: 8 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.

# v3.0

- Adds Django 5.0 to build matrix
- Adds Python 3.12 to build matrix

No code changes.

# v3.0

- Adds support for Python 3.10 and 3.11
- Adds support for Django 4.0 and 4.1
- Drops support for Django 3.1
- Drops support for Django 3.1
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 yunojuno
Copyright (c) 2023 yunojuno

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
3 changes: 2 additions & 1 deletion README.md → README
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ It can be used as the primary key, or simple another key on your models.
- Ability to work with the UID generation spec of your choice.
- Support for prefixing the ID on a per-model basis à la Stripe. e.g `cus_` => `cus_cjld2cjxh0000qzrmn831i7rn`
- Support for all database backends that support the `CharField`.
- Support for Python 3.9 & above only.
- Support for Python 3.8 & above only.

## 🤷 Why?

To get us a global namespace of collision-resistant IDs that:
Expand Down
3 changes: 1 addition & 2 deletions charidfield/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

def prefixed_default(default: Callable | str, *, prefix: str) -> Callable:
if callable(default):
return lambda: f"{prefix}{default()}" # type: ignore[operator]
return lambda: f"{prefix}{default()}"
else:
return lambda: f"{prefix}{default}"

Expand All @@ -29,7 +29,6 @@ def __init__(
*args: Any,
**kwargs: Any,
) -> None:

self.prefix = prefix

self.init_default = default
Expand Down
29 changes: 14 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,48 +1,47 @@
[tool.poetry]
name = "django-charid-field"
version = "0.3"
version = "0.4"
description = "Provides a char-based, prefixable ID field for your Django models. Supports cuid, ksuid, ulid, et al."
license = "MIT"
authors = ["YunoJuno <code@yunojuno.com>"]
maintainers = ["YunoJuno <code@yunojuno.com>"]
readme = "README.md"
readme = "README"
repository = "https://github.com/yunojuno/django-charid-field"
documentation = "https://github.com/yunojuno/django-charid-field/blob/master/README.md"
documentation = "https://github.com/yunojuno/django-charid-field/blob/master/README"
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: Web Environment",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"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",
]
packages = [{ include = "charidfield" }]

[tool.poetry.dependencies]
python = "^3.8"
django = "^3.2 || ^4.0"
django = "^3.2 || ^4.0 || ^5.0"

[tool.poetry.dev-dependencies]
[tool.poetry.group.test.dependencies]
coverage = "*"
pytest = "*"
pytest-cov = "*"
pytest-django = "*"
coverage = "*"
pylint = "*"
flake8 = "*"
flake8-bandit = "*"
flake8-docstrings = "*"
isort = "*"
tox = "*"

[tool.poetry.group.dev.dependencies]
black = "*"
mypy = "*"
pre-commit = "*"
black = "*"
freezegun = "*"
tox = "*"
ruff = "*"

[build-system]
requires = ["poetry_core>=1.0.0"]
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import time
import re
import time

ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz"

Expand Down
4 changes: 2 additions & 2 deletions tests/models.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from django.db import models
from functools import partial

from django.db import models

from charidfield import CharIDField

from .helpers import generate_test_uid


# To show off the recommended partial-usage; in production code you would
# likely be wrapping your own chosen ID generation scheme with a field of
# its own, e.g CuidField, KsuidField, UlidField, etc.
Expand Down
Loading

0 comments on commit 814b0fe

Please sign in to comment.