Skip to content

Commit a797e58

Browse files
chore: Migrate to uv+hatchling (#217)
1 parent bad94ff commit a797e58

File tree

19 files changed

+1099
-1255
lines changed

19 files changed

+1099
-1255
lines changed

.github/workflows/release.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ jobs:
1111
steps:
1212
- uses: actions/checkout@v3
1313
- name: Set up Python
14-
uses: actions/setup-python@v4
14+
uses: astral-sh/setup-uv@v5
1515
with:
1616
python-version: "3.10"
1717
- name: Build artifacts
1818
run: |
19-
pip install -q wheel
20-
python setup.py sdist bdist_wheel
19+
uvx --from build python -m build --installer uv
2120
- name: Create release
22-
uses: softprops/action-gh-release@v1
21+
uses: softprops/action-gh-release@v2
2322
with:
2423
files: dist/*

.github/workflows/test.yml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,17 @@ jobs:
3838
- 27017:27017
3939
steps:
4040
- uses: actions/checkout@v3
41-
- name: Install poetry
42-
run: pipx install poetry
4341
- name: Set up Python ${{ matrix.python-version }}
44-
uses: actions/setup-python@v4
42+
uses: astral-sh/setup-uv@v5
4543
with:
44+
enable-cache: true
4645
python-version: ${{ matrix.python }}
47-
cache: 'poetry'
48-
- name: Cache virtualenv
49-
uses: actions/cache@v3
50-
with:
51-
key: venv-${{ runner.os }}-${{ steps.setup_python.outputs.python-version}}-${{ hashFiles('poetry.lock') }}
52-
path: .venv
5346
- name: Set up env
5447
run: |
55-
poetry install -q
56-
poetry run pip install -q "${{ matrix.django }}"
48+
uv sync --group dev
49+
uv pip install -q "${{ matrix.django }}"
5750
- name: Run tests
5851
run: |
59-
poetry run ruff .
60-
poetry run ruff format --check .
61-
poetry run python -m pytest
52+
uv run ruff check .
53+
uv run ruff format --check .
54+
uv run python -m pytest

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ publish:
1212
git push --follow-tags
1313

1414
test:
15-
poetry run python -m pytest
15+
pytest
1616

1717
codegen:
1818
python codegen.py

README.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,13 @@ How to run example app
132132
----------------------
133133
.. code::
134134
135-
poetry install
136-
poetry run pip install -r example/tumblelog/requirements.txt
137-
poetry run python example/tumblelog/manage.py runserver
135+
uv sync --group dev
136+
uv pip install -r example/tumblelog/requirements.txt
137+
uv run python example/tumblelog/manage.py runserver
138138
139139
140140
How to run tests
141141
----------------
142142
.. code::
143143
144-
poetry install
145-
poetry run python -m pytest
144+
uv run python -m pytest

VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

django_mongoengine/document.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,11 @@ class DynamicEmbeddedDocument(
112112

113113
if TYPE_CHECKING:
114114

115-
class Document(DjangoFlavor, me.Document):
116-
...
115+
class Document(DjangoFlavor, me.Document): ...
117116

118-
class DynamicDocument(DjangoFlavor, me.DynamicDocument):
119-
...
117+
class DynamicDocument(DjangoFlavor, me.DynamicDocument): ...
120118

121119
class EmbeddedDocument(DjangoFlavor, me.EmbeddedDocument):
122120
_instance: Document
123121

124-
class DynamicEmbeddedDocument(DjangoFlavor, me.DynamicEmbeddedDocument):
125-
...
122+
class DynamicEmbeddedDocument(DjangoFlavor, me.DynamicEmbeddedDocument): ...

django_mongoengine/forms/document_options.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class DocumentMetaWrapper:
5151

5252
_pk = None
5353
pk_name = None
54-
app_label = None
5554
object_name = None
5655
model_name = None
5756
verbose_name = None

django_mongoengine/mongo_admin/management/commands/createmongodbsuperuser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Management utility to create superusers.
33
"""
4+
45
import getpass
56
import re
67
import sys

django_mongoengine/mongo_admin/validation.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,11 @@ def _validate(cls, model):
172172
for idx, inline in enumerate(cls.inlines):
173173
if not issubclass(inline, BaseDocumentAdmin):
174174
raise ImproperlyConfigured(
175-
"'%s.inlines[%d]' does not inherit "
176-
"from BaseModelAdmin." % (cls.__name__, idx)
175+
"'%s.inlines[%d]' does not inherit from BaseModelAdmin." % (cls.__name__, idx)
177176
)
178177
if not inline.document:
179178
raise ImproperlyConfigured(
180-
"'document' is a required attribute "
181-
"of '%s.inlines[%d]'." % (cls.__name__, idx)
179+
"'document' is a required attribute of '%s.inlines[%d]'." % (cls.__name__, idx)
182180
)
183181
if not issubclass(inline.document, BaseDocument):
184182
raise ImproperlyConfigured(
@@ -195,7 +193,7 @@ def validate_inline(cls, parent, parent_model):
195193
f = get_field(cls, cls.model, cls.model._meta, "fk_name", cls.fk_name)
196194
if not isinstance(f, models.ForeignKey):
197195
raise ImproperlyConfigured(
198-
"'%s.fk_name is not an instance of " "models.ForeignKey." % cls.__name__
196+
"'%s.fk_name is not an instance of models.ForeignKey." % cls.__name__
199197
)
200198

201199
if not issubclass(cls, EmbeddedDocumentAdmin):
@@ -217,7 +215,7 @@ def validate_inline(cls, parent, parent_model):
217215
# formset
218216
if hasattr(cls, "formset") and not issubclass(cls.formset, BaseDocumentFormSet):
219217
raise ImproperlyConfigured(
220-
"'%s.formset' does not inherit from " "BaseDocumentFormSet." % cls.__name__
218+
"'%s.formset' does not inherit from BaseDocumentFormSet." % cls.__name__
221219
)
222220

223221
# exclude
@@ -285,8 +283,7 @@ def validate_base(cls, model):
285283
check_isseq(cls, "fieldsets[%d]" % idx, fieldset)
286284
if len(fieldset) != 2:
287285
raise ImproperlyConfigured(
288-
"'%s.fieldsets[%d]' does not "
289-
"have exactly two elements." % (cls.__name__, idx)
286+
"'%s.fieldsets[%d]' does not have exactly two elements." % (cls.__name__, idx)
290287
)
291288
check_isdict(cls, "fieldsets[%d][1]" % idx, fieldset[1])
292289
if "fields" not in fieldset[1]:
@@ -297,7 +294,7 @@ def validate_base(cls, model):
297294
for fields in fieldset[1]["fields"]:
298295
# The entry in fields might be a tuple. If it is a standalone
299296
# field, make it into a tuple to make processing easier.
300-
if type(fields) != tuple:
297+
if not isinstance(fields, tuple):
301298
fields = (fields,)
302299
for field in fields:
303300
if field in cls.readonly_fields:
@@ -347,7 +344,7 @@ def validate_base(cls, model):
347344
issubclass(cls.form, BaseModelForm)
348345
or cls.form.__class__.__name__ == "DocumentFormMetaclass"
349346
):
350-
raise ImproperlyConfigured("%s.form does not inherit from " "BaseModelForm." % cls.__name__)
347+
raise ImproperlyConfigured("%s.form does not inherit from BaseModelForm." % cls.__name__)
351348

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

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

372369
# radio_fields

django_mongoengine/mongo_auth/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ def get_profile(self):
358358
if not hasattr(self, "_profile_cache"):
359359
if not getattr(settings, "AUTH_PROFILE_MODULE", False):
360360
raise SiteProfileNotAvailable(
361-
"You need to set AUTH_PROFILE_MO" "DULE in your project settings"
361+
"You need to set AUTH_PROFILE_MODULE in your project settings"
362362
)
363363
try:
364364
app_label, model_name = settings.AUTH_PROFILE_MODULE.split(".")

django_mongoengine/queryset.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,5 +131,4 @@ class QuerySetManager(Generic[_M], qs.QuerySetManager):
131131
default = QuerySet
132132
if TYPE_CHECKING:
133133

134-
def __get__(self, instance: object, cls: type[_M]) -> QuerySet[_M]:
135-
...
134+
def __get__(self, instance: object, cls: type[_M]) -> QuerySet[_M]: ...

example/tumblelog/tumblelog/wsgi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
framework.
1414
1515
"""
16+
1617
import os
1718

1819
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tumblelog.settings")

0 commit comments

Comments
 (0)