Skip to content

Commit dc8516b

Browse files
CodingWithSakshamintgr
authored andcommitted
Switch to uv to manage dev dependencies
Co-authored-by: CodingWithSaksham <[email protected]>
1 parent 04fafaf commit dc8516b

File tree

10 files changed

+1243
-138
lines changed

10 files changed

+1243
-138
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ trim_trailing_whitespace = true
1111

1212
[*.{py, pyi}]
1313
indent_size = 4
14+
15+
[*.toml]
16+
indent_size = 2

.github/workflows/test.yml

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
# 15:41 UTC every day
1111
- cron: "41 15 * * *"
1212

13+
env:
14+
UV_FROZEN: true # https://docs.astral.sh/uv/configuration/environment/#uv_frozen
15+
1316
permissions:
1417
contents: read
1518

@@ -24,74 +27,72 @@ jobs:
2427
strategy:
2528
fail-fast: false
2629
matrix:
27-
python-version: ['3.10', '3.11', '3.12', '3.13']
30+
python-version: ["3.10", "3.11", "3.12", "3.13"]
2831
steps:
2932
- uses: actions/checkout@v5
33+
- name: Install uv
34+
uses: astral-sh/setup-uv@v6
3035
- name: Set up Python ${{ matrix.python-version }}
3136
uses: actions/setup-python@v6
3237
with:
3338
python-version: ${{ matrix.python-version }}
3439
- name: Install dependencies
35-
run: |
36-
pip install -U pip "setuptools<79.0.0" wheel
37-
SETUPTOOLS_ENABLE_FEATURES=legacy-editable pip install -r ./requirements.txt
40+
run: uv sync
3841
- name: Run mypy on plugin code
39-
run: mypy --strict mypy_drf_plugin
42+
run: uv run mypy --strict mypy_drf_plugin
4043
- name: Run mypy on scripts and utils
41-
run: mypy --strict scripts
44+
run: uv run mypy --strict scripts
4245
- name: Run mypy on stubs
43-
run: mypy --cache-dir=/dev/null --no-incremental rest_framework-stubs
46+
run: uv run mypy --cache-dir=/dev/null --no-incremental rest_framework-stubs
4447

4548
test:
4649
timeout-minutes: 10
4750
runs-on: ubuntu-latest
4851
strategy:
4952
fail-fast: false
5053
matrix:
51-
python-version: ['3.10', '3.11', '3.12', '3.13']
54+
python-version: ["3.10", "3.11", "3.12", "3.13"]
5255
steps:
5356
- uses: actions/checkout@v5
5457
- name: Setup system dependencies
5558
run: |
5659
sudo apt-get update
5760
sudo apt-get install binutils libproj-dev gdal-bin
61+
- name: Install uv
62+
uses: astral-sh/setup-uv@v6
5863
- name: Set up Python ${{ matrix.python-version }}
5964
uses: actions/setup-python@v6
6065
with:
6166
python-version: ${{ matrix.python-version }}
6267
- name: Install dependencies
63-
run: |
64-
pip install -U pip "setuptools<79.0.0" wheel
65-
SETUPTOOLS_ENABLE_FEATURES=legacy-editable pip install -r ./requirements.txt
66-
68+
run: uv sync
6769
- name: Run tests
68-
# Suppress errors from other packages due to https://github.com/typeddjango/pytest-mypy-plugins/issues/134
69-
run: pytest --mypy-only-local-stub
70+
run: uv run pytest
7071

7172
stubtest:
7273
timeout-minutes: 10
7374
runs-on: ubuntu-latest
7475
strategy:
7576
matrix:
76-
python-version: ['3.13']
77+
python-version: ["3.13"]
7778
fail-fast: false
7879
steps:
7980
- uses: actions/checkout@v5
8081
- name: Setup system dependencies
8182
run: |
8283
sudo apt-get update
8384
sudo apt-get install binutils libproj-dev gdal-bin
85+
- name: Install uv
86+
uses: astral-sh/setup-uv@v6
8487
- name: Set up Python ${{ matrix.python-version }}
8588
uses: actions/setup-python@v6
8689
with:
8790
python-version: ${{ matrix.python-version }}
8891
- name: Install dependencies
89-
run: |
90-
pip install -U pip "setuptools<79.0.0" wheel
91-
SETUPTOOLS_ENABLE_FEATURES=legacy-editable pip install -r ./requirements.txt
92+
run: uv sync
9293

9394
- name: Run stubtest
94-
run: bash ./scripts/stubtest.sh
95+
run: uv run ./scripts/stubtest.sh
9596

9697
build-and-check:
9798
runs-on: ubuntu-latest
@@ -101,12 +102,8 @@ jobs:
101102
fetch-tags: true
102103
- uses: actions/setup-python@v6
103104
with:
104-
python-version: '3.13'
105-
- name: Install dependencies
106-
run: python3 -m pip install --upgrade build twine
105+
python-version: "3.13"
107106
- name: Build
108-
run: |
109-
python3 -m build --sdist --wheel .
107+
run: uv build
110108
- name: Check package metadata
111-
run: |
112-
twine check --strict dist/*
109+
run: uvx twine check --strict dist/*

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ out/
1212
pip-wheel-metadata/
1313
stubgen/
1414
build/
15+
dist/

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,17 @@ In order to be able to continously sync your fork with the origin repository's m
3939

4040
After your repository is setup you will then need to create and activate a git ignored virtual env, e.g.:
4141

42+
# TODO FIXME needs updating
43+
4244
```bash
4345
python3 -m venv .venv
4446
source .venv/bin/activate
4547
```
4648

4749
Then install the dev requirements:
4850

51+
# TODO FIXME needs updating
52+
4953
```bash
5054
SETUPTOOLS_ENABLE_FEATURES=legacy-editable pip install -r ./requirements.txt
5155
```

pyproject.toml

Lines changed: 112 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,117 @@
1+
[project]
2+
name = "djangorestframework-stubs"
3+
version = "3.16.1"
4+
requires-python = ">=3.10"
5+
description = "Mypy stubs for Django"
6+
readme = "README.md"
7+
license = "MIT"
8+
license-files = ["LICENSE.txt"]
9+
authors = [{ name = "Maksim Kurnikov", email = "[email protected]" }]
10+
maintainers = [
11+
{ name = "Marti Raudsepp", email = "[email protected]" },
12+
{ name = "Nikita Sobolev", email = "[email protected]" },
13+
]
14+
classifiers = [
15+
"License :: OSI Approved :: MIT License",
16+
"Operating System :: OS Independent",
17+
"Programming Language :: Python :: 3.10",
18+
"Programming Language :: Python :: 3.11",
19+
"Programming Language :: Python :: 3.12",
20+
"Programming Language :: Python :: 3.13",
21+
"Typing :: Typed",
22+
"Framework :: Django",
23+
]
24+
dependencies = [
25+
"django-stubs>=5.2.5",
26+
"typing-extensions>=4.0",
27+
"requests>=2.0",
28+
"types-requests",
29+
"types-PyYAML",
30+
]
31+
32+
[project.urls]
33+
Homepage = "https://github.com/typeddjango/djangorestframework-stubs"
34+
Funding = "https://github.com/sponsors/typeddjango"
35+
"Release notes" = "https://github.com/typeddjango/djangorestframework-stubs/releases"
36+
37+
[project.optional-dependencies]
38+
compatible-mypy = ["mypy>=1.13,<1.19", "django-stubs[compatible-mypy]"]
39+
coreapi = ["coreapi>=2.0.0"]
40+
markdown = ["types-Markdown>=0.1.5"]
41+
42+
[dependency-groups]
43+
dev = [
44+
"wheel",
45+
"mypy==1.18.2",
46+
"pre-commit==4.3.0",
47+
"pytest==8.4.2",
48+
"pytest-mypy-plugins==3.2.0",
49+
"djangorestframework==3.16.1",
50+
"types-pytz==2025.2.0.20250809",
51+
"types-requests==2.32.4.20250913",
52+
"types-urllib3==1.26.25.14",
53+
"types-Pygments==2.19.0.20250809",
54+
"types-pyyaml==6.0.12.20250915",
55+
"django-stubs[compatible-mypy] @ git+https://github.com/typeddjango/django-stubs",
56+
"django-stubs-ext @ git+https://github.com/typeddjango/django-stubs#subdirectory=ext",
57+
"djangorestframework-stubs[compatible-mypy,coreapi,markdown]",
58+
]
59+
60+
[build-system]
61+
requires = ["uv_build>=0.8.19,<0.9.0"]
62+
build-backend = "uv_build"
63+
64+
[tool.uv.build-backend]
65+
module-name = ["rest_framework-stubs", "mypy_drf_plugin"]
66+
module-root = ""
67+
68+
[tool.pytest.ini_options]
69+
pythonpath = ["."]
70+
testpaths = ["tests"]
71+
addopts = [
72+
"--tb=native",
73+
"-s",
74+
"-v",
75+
"--cache-clear",
76+
"--mypy-extension-hook=scripts.tests_extension_hook.django_plugin_hook",
77+
# Suppress errors from other packages due to https://github.com/typeddjango/pytest-mypy-plugins/issues/134
78+
"--mypy-only-local-stub",
79+
"--mypy-ini-file=mypy.ini"
80+
]
81+
82+
# Ruff configuration
183
[tool.ruff]
284
line-length = 120
385
target-version = "py310"
86+
487
# See Rules in Ruff documentation: https://docs.astral.sh/ruff/rules/
588
[tool.ruff.lint]
689
select = [
7-
"B", # bugbear
8-
"E", # pycodestyle
9-
"F", # pyflakes
10-
"INP", # flake8-tidy-imports
11-
"W", # pycodestyle
12-
"I", # isort
13-
"UP", # pyupgrade
14-
"TID251", # Disallowed imports (flake8-tidy-imports.banned-api)
15-
"PYI", # flake8-pyi
16-
"RUF100", # Equivalent to flake8-noqa NQA103
17-
"PGH004", # Equivalent to flake8-noqa NQA104
18-
"PGH003", # Disallowed blanket `type: ignore` annotations.
90+
"B", # bugbear
91+
"E", # pycodestyle
92+
"F", # pyflakes
93+
"INP", # flake8-tidy-imports
94+
"W", # pycodestyle
95+
"I", # isort
96+
"UP", # pyupgrade
97+
"TID251", # Disallowed imports (flake8-tidy-imports.banned-api)
98+
"PYI", # flake8-pyi
99+
"RUF100", # Equivalent to flake8-noqa NQA103
100+
"PGH004", # Equivalent to flake8-noqa NQA104
101+
"PGH003", # Disallowed blanket `type: ignore` annotations.
19102
]
20103
ignore = ["PYI021", "PYI024", "PYI041", "PYI043"]
21104

22105
[tool.ruff.lint.per-file-ignores]
23106
"*.pyi" = [
24-
"B",
25-
"E501",
26-
"E741",
27-
"E743",
28-
"F403", # Use wildcard import
29-
"F405",
30-
"F822",
31-
"F821",
107+
"B",
108+
"E501",
109+
"E741",
110+
"E743",
111+
"F403", # Use wildcard import
112+
"F405",
113+
"F822",
114+
"F821",
32115
]
33116
"rest_framework-stubs/compat.pyi" = ["PYI042"]
34117

@@ -39,5 +122,12 @@ ignore = ["PYI021", "PYI024", "PYI041", "PYI043"]
39122
split-on-trailing-comma = false
40123
extra-standard-library = ["_typeshed"]
41124

42-
[build-system]
43-
requires = ["setuptools<79.0.0", "wheel"]
125+
126+
[tool.django-stubs]
127+
django_settings_module = "scripts.drf_tests_settings"
128+
129+
# Pyright configuration
130+
[tool.pyright]
131+
pythonVersion = "3.10"
132+
include = ["rest_framework-stubs", "tests"]
133+
exclude = [".venv", ".mypy_cache", ".pytest_cache", ".idea"]

pytest.ini

Lines changed: 0 additions & 10 deletions
This file was deleted.

rest_framework-stubs/py.typed

Whitespace-only changes.

setup.cfg

Lines changed: 0 additions & 13 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)