Skip to content

Commit

Permalink
add CuidField and extras needed (#33)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
joshuadavidthomas and pre-commit-ci[bot] committed Apr 26, 2024
1 parent 30a2ea6 commit 9565dcc
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 30 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ and this project attempts to adhere to [Semantic Versioning](https://semver.org/

## [Unreleased]

### Added

- Added a `CuidField` and extra dependencies needed to use it. Install the package with `django-twc-toolbox[cuid]` in order to use it.

## [0.3.1]

### Added
Expand Down
44 changes: 14 additions & 30 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ build-backend = "hatchling.build"
requires = ["hatchling"]

[project]
authors = [
{name = "Josh Thomas", email = "josh@joshthomas.dev"}
]
authors = [{name = "Josh Thomas", email = "josh@joshthomas.dev"}]
classifiers = [
"Development Status :: 3 - Alpha",
"Framework :: Django",
Expand All @@ -24,9 +22,7 @@ classifiers = [
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython"
]
dependencies = [
"django>=3.2"
]
dependencies = ["django>=3.2"]
description = "Various tools for Django projects at The Westervelt Company."
dynamic = ["version"]
keywords = []
Expand All @@ -36,6 +32,7 @@ readme = "README.md"
requires-python = ">=3.8"

[project.optional-dependencies]
cuid = ["cuid", "django-charid-field"]
dev = [
"bumpver",
"copier",
Expand Down Expand Up @@ -80,15 +77,9 @@ tag = false
version_pattern = "MAJOR.MINOR.PATCH[PYTAGNUM]"

[tool.bumpver.file_patterns]
".copier/package.yml" = [
'current_version: {version}'
]
"src/django_twc_toolbox/__init__.py" = [
'__version__ = "{version}"'
]
"tests/test_version.py" = [
'assert __version__ == "{version}"'
]
".copier/package.yml" = ['current_version: {version}']
"src/django_twc_toolbox/__init__.py" = ['__version__ = "{version}"']
"tests/test_version.py" = ['assert __version__ == "{version}"']

[tool.coverage.paths]
source = ["src"]
Expand All @@ -105,10 +96,7 @@ exclude_lines = [
fail_under = 75

[tool.coverage.run]
omit = [
"src/django_twc_toolbox/migrations/*",
"tests/*"
]
omit = ["src/django_twc_toolbox/migrations/*", "tests/*"]
source = ["django_twc_toolbox"]

[tool.django-stubs]
Expand All @@ -119,10 +107,7 @@ strict_settings = false
indent = 2

[tool.hatch.build]
exclude = [
".*",
"Justfile"
]
exclude = [".*", "Justfile"]

[tool.hatch.build.targets.wheel]
packages = ["src/django_twc_toolbox"]
Expand All @@ -135,20 +120,19 @@ check_untyped_defs = true
exclude = "docs/.*\\.py$"
mypy_path = "src/"
no_implicit_optional = true
plugins = [
"mypy_django_plugin.main"
]
plugins = ["mypy_django_plugin.main"]
warn_redundant_casts = true
warn_unused_configs = true
warn_unused_ignores = true

[[tool.mypy.overrides]]
ignore_errors = true
ignore_missing_imports = true
module = [
"django_twc_toolbox.*.migrations.*",
"tests.*"
]
module = ["django_twc_toolbox.*.migrations.*", "tests.*"]

[[tool.mypy.overrides]]
ignore_missing_imports = true
module = ["charidfield.*", "cuid.*"]

[tool.mypy_django_plugin]
ignore_missing_model_attributes = true
Expand Down
13 changes: 13 additions & 0 deletions src/django_twc_toolbox/fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from __future__ import annotations

from functools import partial

from charidfield import CharIDField
from cuid import cuid

CuidField = partial(
CharIDField,
default=cuid,
max_length=30,
help_text="cuid-format identifier for this entity.",
)

0 comments on commit 9565dcc

Please sign in to comment.