Skip to content

Commit c664cef

Browse files
authored
Use uv (#153)
* Use uv * Name CI instead of Test * Use master instead of main * Remove 100% coverage condition
1 parent 8b85d35 commit c664cef

File tree

11 files changed

+1065
-144
lines changed

11 files changed

+1065
-144
lines changed

.github/workflows/main.yml

+28-18
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,40 @@ on:
66
pull_request:
77
branches: ["master"]
88

9-
109
jobs:
11-
build:
12-
10+
test:
1311
runs-on: ubuntu-latest
1412
strategy:
15-
fail-fast: false
1613
matrix:
1714
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
18-
1915
steps:
2016
- uses: actions/checkout@v4
21-
- name: Set up Python ${{ matrix.python-version }}
22-
uses: actions/setup-python@v5
17+
18+
- name: Install uv
19+
uses: astral-sh/setup-uv@v2
2320
with:
24-
python-version: ${{ matrix.python-version }}
21+
version: "0.4.12"
22+
enable-cache: true
23+
24+
- name: Set up Python ${{ matrix.python-version }}
25+
run: uv python install ${{ matrix.python-version }}
26+
2527
- name: Install dependencies
26-
run: |
27-
python -m pip install --upgrade pip
28-
pip install .[dev]
29-
- name: Lint
30-
if: matrix.python-version == '3.8'
31-
run: |
32-
ruff multipart tests
33-
- name: Test with pytest
34-
run: |
35-
inv test
28+
run: uv sync --python ${{ matrix.python-version }} --frozen
29+
30+
- name: Run tests
31+
run: scripts/test
32+
33+
- name: Run linters
34+
run: scripts/lint
35+
36+
# https://github.com/marketplace/actions/alls-green#why used for branch protection checks
37+
check:
38+
if: always()
39+
needs: [test]
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Decide whether the needed jobs succeeded or failed
43+
uses: re-actors/alls-green@release/v1
44+
with:
45+
jobs: ${{ toJSON(needs) }}

.github/workflows/publish.yml

+4
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,21 @@ jobs:
2222

2323
steps:
2424
- uses: actions/checkout@v4
25+
2526
- name: Set up Python 3.10
2627
uses: actions/setup-python@v5
2728
with:
2829
python-version: "3.10"
30+
2931
- name: Install dependencies
3032
run: |
3133
python -m pip install --upgrade pip
3234
pip install build
3335
pip install -e '.[docs]'
36+
3437
- name: Build package
3538
run: python -m build
39+
3640
- name: Publish package
3741
uses: pypa/gh-action-pypi-publish@v1.8.14
3842
with:

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# [Python-Multipart](https://kludex.github.io/python-multipart/)
22

3-
[![Build Status](https://github.com/Kludex/python-multipart/workflows/CI/badge.svg)](https://github.com/Kludex/python-multipart/actions)
43
[![Package version](https://badge.fury.io/py/python-multipart.svg)](https://pypi.python.org/pypi/python-multipart)
54
[![Supported Python Version](https://img.shields.io/pypi/pyversions/python-multipart.svg?color=%2334D058)](https://pypi.org/project/python-multipart)
65

multipart/multipart.py

+9-13
Original file line numberDiff line numberDiff line change
@@ -57,25 +57,19 @@ class FileConfig(TypedDict, total=False):
5757
MAX_MEMORY_FILE_SIZE: int
5858

5959
class _FormProtocol(Protocol):
60-
def write(self, data: bytes) -> int:
61-
...
60+
def write(self, data: bytes) -> int: ...
6261

63-
def finalize(self) -> None:
64-
...
62+
def finalize(self) -> None: ...
6563

66-
def close(self) -> None:
67-
...
64+
def close(self) -> None: ...
6865

6966
class FieldProtocol(_FormProtocol, Protocol):
70-
def __init__(self, name: bytes) -> None:
71-
...
67+
def __init__(self, name: bytes) -> None: ...
7268

73-
def set_none(self) -> None:
74-
...
69+
def set_none(self) -> None: ...
7570

7671
class FileProtocol(_FormProtocol, Protocol):
77-
def __init__(self, file_name: bytes | None, field_name: bytes | None, config: FileConfig) -> None:
78-
...
72+
def __init__(self, file_name: bytes | None, field_name: bytes | None, config: FileConfig) -> None: ...
7973

8074
OnFieldCallback = Callable[[FieldProtocol], None]
8175
OnFileCallback = Callable[[FileProtocol], None]
@@ -136,14 +130,16 @@ class MultipartState(IntEnum):
136130
LOWER_Z = b"z"[0]
137131
NULL = b"\x00"[0]
138132

133+
# fmt: off
139134
# Mask for ASCII characters that can be http tokens.
140-
# Per RFC7230 - 3.2.6, this is all alpha-numeric characters
135+
# Per RFC7230 - 3.2.6, this is all alpha-numeric characters
141136
# and these: !#$%&'*+-.^_`|~
142137
TOKEN_CHARS_SET = frozenset(
143138
b"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
144139
b"abcdefghijklmnopqrstuvwxyz"
145140
b"0123456789"
146141
b"!#$%&'*+-.^_`|~")
142+
# fmt: on
147143

148144

149145
def ord_char(c: int) -> int:

pyproject.toml

+7-6
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ classifiers = [
3030
]
3131
dependencies = []
3232

33-
[project.optional-dependencies]
34-
dev = [
33+
[tool.uv]
34+
dev-dependencies = [
3535
"atomicwrites==1.4.1",
3636
"attrs==23.2.0",
3737
"coverage==7.4.4",
@@ -45,10 +45,8 @@ dev = [
4545
"invoke==2.2.0",
4646
"pytest-timeout==2.3.1",
4747
"ruff==0.3.4",
48-
"hatch",
4948
"atheris==2.3.0; python_version != '3.12'",
50-
]
51-
docs = [
49+
# Documentation
5250
"mkdocs==1.5.3",
5351
"mkdocs-material==9.5.16",
5452
"mkdocstrings==0.24.1",
@@ -69,7 +67,7 @@ path = "multipart/__init__.py"
6967
packages = ["multipart"]
7068

7169
[tool.hatch.build.targets.sdist]
72-
include = ["/multipart", "/tests"]
70+
include = ["/multipart", "/tests", "CHANGELOG.md", "LICENSE.txt"]
7371

7472
[tool.ruff]
7573
line-length = 120
@@ -90,6 +88,9 @@ branch = false
9088
omit = ["tests/*"]
9189

9290
[tool.coverage.report]
91+
# fail_under = 100
92+
skip_covered = true
93+
show_missing = true
9394
exclude_lines = [
9495
"pragma: no cover",
9596
"raise NotImplementedError",

requirements.txt

-11
This file was deleted.

scripts/lint

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh -e
2+
3+
set -x
4+
5+
uvx ruff check --fix
6+
uvx ruff format

scripts/test

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh -e
2+
3+
set -x # print executed commands to the terminal
4+
5+
uv run coverage run -m pytest "${@}"
6+
uv run coverage report

tasks.py

-84
This file was deleted.

tox.ini

-11
This file was deleted.

0 commit comments

Comments
 (0)