Skip to content

chore: Migrate to uv+hatchling #217

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

Merged
merged 6 commits into from
Apr 13, 2025
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
7 changes: 3 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
uses: astral-sh/setup-uv@v5
with:
python-version: "3.10"
- name: Build artifacts
run: |
pip install -q wheel
python setup.py sdist bdist_wheel
uvx --from build python -m build --installer uv
- name: Create release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
files: dist/*
21 changes: 7 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,17 @@ jobs:
- 27017:27017
steps:
- uses: actions/checkout@v3
- name: Install poetry
run: pipx install poetry
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
python-version: ${{ matrix.python }}
cache: 'poetry'
- name: Cache virtualenv
uses: actions/cache@v3
with:
key: venv-${{ runner.os }}-${{ steps.setup_python.outputs.python-version}}-${{ hashFiles('poetry.lock') }}
path: .venv
- name: Set up env
run: |
poetry install -q
poetry run pip install -q "${{ matrix.django }}"
uv sync --group dev
uv pip install -q "${{ matrix.django }}"
- name: Run tests
run: |
poetry run ruff .
poetry run ruff format --check .
poetry run python -m pytest
uv run ruff check .
uv run ruff format --check .
uv run python -m pytest
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ publish:
git push --follow-tags

test:
poetry run python -m pytest
pytest

codegen:
python codegen.py
Expand Down
9 changes: 4 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,13 @@ How to run example app
----------------------
.. code::

poetry install
poetry run pip install -r example/tumblelog/requirements.txt
poetry run python example/tumblelog/manage.py runserver
uv sync --group dev
uv pip install -r example/tumblelog/requirements.txt
uv run python example/tumblelog/manage.py runserver


How to run tests
----------------
.. code::

poetry install
poetry run python -m pytest
uv run python -m pytest
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

9 changes: 3 additions & 6 deletions django_mongoengine/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,11 @@ class DynamicEmbeddedDocument(

if TYPE_CHECKING:

class Document(DjangoFlavor, me.Document):
...
class Document(DjangoFlavor, me.Document): ...

class DynamicDocument(DjangoFlavor, me.DynamicDocument):
...
class DynamicDocument(DjangoFlavor, me.DynamicDocument): ...

class EmbeddedDocument(DjangoFlavor, me.EmbeddedDocument):
_instance: Document

class DynamicEmbeddedDocument(DjangoFlavor, me.DynamicEmbeddedDocument):
...
class DynamicEmbeddedDocument(DjangoFlavor, me.DynamicEmbeddedDocument): ...
1 change: 0 additions & 1 deletion django_mongoengine/forms/document_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class DocumentMetaWrapper:

_pk = None
pk_name = None
app_label = None
object_name = None
model_name = None
verbose_name = None
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Management utility to create superusers.
"""

import getpass
import re
import sys
Expand Down
21 changes: 9 additions & 12 deletions django_mongoengine/mongo_admin/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,11 @@ def _validate(cls, model):
for idx, inline in enumerate(cls.inlines):
if not issubclass(inline, BaseDocumentAdmin):
raise ImproperlyConfigured(
"'%s.inlines[%d]' does not inherit "
"from BaseModelAdmin." % (cls.__name__, idx)
"'%s.inlines[%d]' does not inherit from BaseModelAdmin." % (cls.__name__, idx)
)
if not inline.document:
raise ImproperlyConfigured(
"'document' is a required attribute "
"of '%s.inlines[%d]'." % (cls.__name__, idx)
"'document' is a required attribute of '%s.inlines[%d]'." % (cls.__name__, idx)
)
if not issubclass(inline.document, BaseDocument):
raise ImproperlyConfigured(
Expand All @@ -195,7 +193,7 @@ def validate_inline(cls, parent, parent_model):
f = get_field(cls, cls.model, cls.model._meta, "fk_name", cls.fk_name)
if not isinstance(f, models.ForeignKey):
raise ImproperlyConfigured(
"'%s.fk_name is not an instance of " "models.ForeignKey." % cls.__name__
"'%s.fk_name is not an instance of models.ForeignKey." % cls.__name__
)

if not issubclass(cls, EmbeddedDocumentAdmin):
Expand All @@ -217,7 +215,7 @@ def validate_inline(cls, parent, parent_model):
# formset
if hasattr(cls, "formset") and not issubclass(cls.formset, BaseDocumentFormSet):
raise ImproperlyConfigured(
"'%s.formset' does not inherit from " "BaseDocumentFormSet." % cls.__name__
"'%s.formset' does not inherit from BaseDocumentFormSet." % cls.__name__
)

# exclude
Expand Down Expand Up @@ -285,8 +283,7 @@ def validate_base(cls, model):
check_isseq(cls, "fieldsets[%d]" % idx, fieldset)
if len(fieldset) != 2:
raise ImproperlyConfigured(
"'%s.fieldsets[%d]' does not "
"have exactly two elements." % (cls.__name__, idx)
"'%s.fieldsets[%d]' does not have exactly two elements." % (cls.__name__, idx)
)
check_isdict(cls, "fieldsets[%d][1]" % idx, fieldset[1])
if "fields" not in fieldset[1]:
Expand All @@ -297,7 +294,7 @@ def validate_base(cls, model):
for fields in fieldset[1]["fields"]:
# The entry in fields might be a tuple. If it is a standalone
# field, make it into a tuple to make processing easier.
if type(fields) != tuple:
if not isinstance(fields, tuple):
fields = (fields,)
for field in fields:
if field in cls.readonly_fields:
Expand Down Expand Up @@ -347,7 +344,7 @@ def validate_base(cls, model):
issubclass(cls.form, BaseModelForm)
or cls.form.__class__.__name__ == "DocumentFormMetaclass"
):
raise ImproperlyConfigured("%s.form does not inherit from " "BaseModelForm." % cls.__name__)
raise ImproperlyConfigured("%s.form does not inherit from BaseModelForm." % cls.__name__)

# filter_vertical
if hasattr(cls, "filter_vertical"):
Expand All @@ -356,7 +353,7 @@ def validate_base(cls, model):
f = get_field(cls, model, opts, "filter_vertical", field)
if not isinstance(f, models.ManyToManyField):
raise ImproperlyConfigured(
"'%s.filter_vertical[%d]' must be " "a ManyToManyField." % (cls.__name__, idx)
"'%s.filter_vertical[%d]' must be a ManyToManyField." % (cls.__name__, idx)
)

# filter_horizontal
Expand All @@ -366,7 +363,7 @@ def validate_base(cls, model):
f = get_field(cls, model, opts, "filter_horizontal", field)
if not isinstance(f, ListField) and not isinstance(f.field, ReferenceField):
raise ImproperlyConfigured(
"'%s.filter_horizontal[%d]' must be " "a ManyToManyField." % (cls.__name__, idx)
"'%s.filter_horizontal[%d]' must be a ManyToManyField." % (cls.__name__, idx)
)

# radio_fields
Expand Down
2 changes: 1 addition & 1 deletion django_mongoengine/mongo_auth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def get_profile(self):
if not hasattr(self, "_profile_cache"):
if not getattr(settings, "AUTH_PROFILE_MODULE", False):
raise SiteProfileNotAvailable(
"You need to set AUTH_PROFILE_MO" "DULE in your project settings"
"You need to set AUTH_PROFILE_MODULE in your project settings"
)
try:
app_label, model_name = settings.AUTH_PROFILE_MODULE.split(".")
Expand Down
3 changes: 1 addition & 2 deletions django_mongoengine/queryset.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,4 @@ class QuerySetManager(Generic[_M], qs.QuerySetManager):
default = QuerySet
if TYPE_CHECKING:

def __get__(self, instance: object, cls: type[_M]) -> QuerySet[_M]:
...
def __get__(self, instance: object, cls: type[_M]) -> QuerySet[_M]: ...
1 change: 1 addition & 0 deletions example/tumblelog/tumblelog/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
framework.

"""

import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tumblelog.settings")
Expand Down
Loading