Skip to content

Commit 624c3fa

Browse files
authored
Switch to UV and drop Python 3.8 (#340)
* Switch to UV, drop python 3.8 Signed-off-by: Fabrice Normandin <[email protected]> * Fix test_subgroups.py issue with line changes Signed-off-by: Fabrice Normandin <[email protected]> --------- Signed-off-by: Fabrice Normandin <[email protected]>
1 parent 26ec008 commit 624c3fa

File tree

77 files changed

+1299
-2151
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1299
-2151
lines changed

.github/workflows/build.yml

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,50 +11,47 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v4
14-
- uses: actions/setup-python@v5
14+
15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v5
1517
with:
18+
version: "0.5.25"
1619
python-version: '3.11'
17-
cache: 'pip'
18-
- run: pip install "pre-commit<4.0.0"
19-
- run: pre-commit --version
20-
- run: pre-commit install
21-
- run: pre-commit run --all-files
20+
- run: uvx pre-commit --version
21+
- run: uvx pre-commit run --all-files
2222

2323
build:
2424
needs: [linting]
2525
runs-on: ubuntu-latest
2626
strategy:
2727
matrix:
28-
python-version: ["3.8", "3.9", "3.10", "3.11"]
28+
python-version: ["3.9", "3.10", "3.11", "3.12"]
2929

3030
steps:
3131
- uses: actions/checkout@v4
32-
- name: Install poetry
33-
run: |
34-
python -m pip install --upgrade pip
35-
pip install poetry
36-
- name: Set up Python ${{ matrix.python-version }}
37-
uses: actions/setup-python@v5
32+
33+
- name: Install uv
34+
uses: astral-sh/setup-uv@v5
3835
with:
36+
version: "0.5.25"
3937
python-version: ${{ matrix.python-version }}
40-
cache: poetry
4138

42-
- name: Install base dependencies
43-
run: poetry install
39+
40+
- name: Install the project (no extras)
41+
run: uv sync
4442

4543
- name: Unit tests with Pytest (no extras)
4644
timeout-minutes: 3
4745
run: |
48-
poetry run pytest --benchmark-disable --cov=simple_parsing --cov-report=xml --cov-append
49-
46+
uv run pytest --benchmark-disable --cov=simple_parsing --cov-report=xml --cov-append
5047
5148
- name: Install extra dependencies
52-
run: poetry install --all-extras
49+
run: uv sync --all-extras
5350

5451
- name: Unit tests with Pytest (with extra dependencies)
5552
timeout-minutes: 3
5653
run: |
57-
poetry run pytest --benchmark-disable --cov=simple_parsing --cov-report=xml --cov-append
54+
uv run pytest --benchmark-disable --cov=simple_parsing --cov-report=xml --cov-append
5855
5956
- name: Upload coverage reports to Codecov
6057
uses: codecov/codecov-action@v4

.github/workflows/python-publish.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,20 @@ jobs:
1919
- uses: actions/checkout@v4
2020
- name: Install poetry
2121
run: pipx install poetry
22-
- name: Set up Python ${{ matrix.python-version }}
23-
uses: actions/setup-python@v5
22+
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v5
2425
with:
26+
version: "0.5.25"
2527
python-version: ${{ matrix.python-version }}
26-
cache: poetry
2728

2829
- name: Install dependencies
2930
run: |
30-
poetry install
31-
poetry self add "poetry-dynamic-versioning[plugin]"
32-
poetry dynamic-versioning enable
31+
uv sync
3332
3433
- name: Publish package
3534
env:
36-
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
37-
run: poetry publish --build
35+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
36+
run: |
37+
uv build
38+
uv publish

.pre-commit-config.yaml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ default_language_version:
33

44
repos:
55
- repo: https://github.com/pre-commit/pre-commit-hooks
6-
rev: v4.4.0
6+
rev: v5.0.0
77
hooks:
88
# list of supported hooks: https://pre-commit.com/hooks.html
99
- id: trailing-whitespace
@@ -32,21 +32,21 @@ repos:
3232
hooks:
3333
# Run the linter.
3434
- id: ruff
35-
args: ['--line-length', '99', "--select", "I,UP", '--fix']
3635
require_serial: true
36+
args: ["--fix"]
3737
# Run the formatter.
3838
- id: ruff-format
39-
args: ['--line-length', '99']
4039
require_serial: true
4140

4241
# python docstring formatting
4342
- repo: https://github.com/myint/docformatter
44-
rev: v1.5.1
43+
rev: eb1df347edd128b30cd3368dddc3aa65edcfac38 # Don't autoupdate until https://github.com/PyCQA/docformatter/issues/293 is fixed
4544
hooks:
4645
- id: docformatter
4746
exclude: ^test/test_docstrings.py
48-
args: [--in-place, --wrap-summaries=99, --wrap-descriptions=99]
4947
require_serial: true
48+
additional_dependencies: [tomli]
49+
5050

5151
# NOTE: Disabling this, since I'm having the glib-c2.29 weird bug.
5252
# # yaml formatting
@@ -79,12 +79,6 @@ repos:
7979
# - mdformat-black
8080
require_serial: true
8181

82-
- repo: https://github.com/python-poetry/poetry
83-
rev: 1.7.0
84-
hooks:
85-
- id: poetry-check
86-
require_serial: true
87-
8882
# word spelling linter
8983
- repo: https://github.com/codespell-project/codespell
9084
rev: v2.2.2

examples/config_files/one_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Example adapted from https://github.com/eladrich/pyrallis#my-first-pyrallis-example-"""
2+
23
from dataclasses import dataclass
34

45
import simple_parsing

examples/container_types/lists_example.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
from dataclasses import dataclass, field
2-
from typing import List
32

43
from simple_parsing import ArgumentParser
54
from simple_parsing.helpers import list_field
65

76

87
@dataclass
98
class Example:
10-
some_integers: List[int] = field(
9+
some_integers: list[int] = field(
1110
default_factory=list
1211
) # This is a list of integers (empty by default)
1312
"""This list is empty, by default.
@@ -19,9 +18,9 @@ class Example:
1918
# When using a list attribute, the dataclasses module requires us to use `dataclass.field()`,
2019
# so each instance of this class has a different list, rather than them sharing the same list.
2120
# To simplify this, you can use `MutableField(value)` which is just a shortcut for `field(default_factory=lambda: value)`.
22-
some_floats: List[float] = list_field(3.14, 2.56)
21+
some_floats: list[float] = list_field(3.14, 2.56)
2322

24-
some_list_of_strings: List[str] = list_field("default_1", "default_2")
23+
some_list_of_strings: list[str] = list_field("default_1", "default_2")
2524
"""This list has a default value of ["default_1", "default_2"]."""
2625

2726

examples/custom_args/custom_args_example.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Example of overwriting auto-generated argparse options with custom ones."""
22

33
from dataclasses import dataclass
4-
from typing import List
54

65
from simple_parsing import ArgumentParser, field
76
from simple_parsing.helpers import list_field
@@ -21,7 +20,7 @@ def parse(cls, args: str = ""):
2120
@dataclass
2221
class Example1:
2322
# A list of animals to take on a walk. (can only be passed 'cat' or 'dog')
24-
pets_to_walk: List[str] = list_field(default=["dog"], choices=["cat", "dog"])
23+
pets_to_walk: list[str] = list_field(default=["dog"], choices=["cat", "dog"])
2524

2625

2726
# passing no arguments uses the default values:

examples/docstrings/docstrings_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ class DocStringsExample:
2222

2323
# comment above 42
2424
attribute4: float = 1.0 # inline comment
25-
"""docstring below (this appears in --help)"""
25+
"""Docstring below (this appears in --help)"""
2626

2727
# comment above (this appears in --help) 46
2828
attribute5: float = 1.0 # inline comment
2929

3030
attribute6: float = 1.0 # inline comment (this appears in --help)
3131

3232
attribute7: float = 1.0 # inline comment
33-
"""docstring below (this appears in --help)"""
33+
"""Docstring below (this appears in --help)"""
3434

3535

3636
parser.add_arguments(DocStringsExample, "example")

examples/inheritance/ml_inheritance_2.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from dataclasses import dataclass, field
2-
from typing import List
32

43
from simple_parsing import ArgumentParser, choice
54
from simple_parsing.helpers import Serializable, list_field
@@ -12,7 +11,7 @@ class ConvBlock(Serializable):
1211
"""A Block of Conv Layers."""
1312

1413
n_layers: int = 4 # number of layers
15-
n_filters: List[int] = list_field(16, 32, 64, 64) # filters per layer
14+
n_filters: list[int] = list_field(16, 32, 64, 64) # filters per layer
1615

1716

1817
@dataclass

examples/merging/multiple_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Config:
1919
run_name: str = "train" # Some parameter for the run name.
2020
some_int: int = 10 # an optional int parameter.
2121
log_dir: str = "logs" # an optional string parameter.
22-
"""the logging directory to use.
22+
"""The logging directory to use.
2323
2424
(This is an attribute docstring for the log_dir attribute, and shows up when using the "--help"
2525
argument!)

examples/merging/multiple_lists_example.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"""
1313

1414
from dataclasses import dataclass, field
15-
from typing import List, Tuple
1615

1716
from simple_parsing import ArgumentParser, ConflictResolution
1817

@@ -21,8 +20,8 @@
2120
class CNNStack:
2221
name: str = "stack"
2322
num_layers: int = 3
24-
kernel_sizes: Tuple[int, int, int] = (7, 5, 5)
25-
num_filters: List[int] = field(default_factory=[32, 64, 64].copy)
23+
kernel_sizes: tuple[int, int, int] = (7, 5, 5)
24+
num_filters: list[int] = field(default_factory=[32, 64, 64].copy)
2625

2726

2827
parser = ArgumentParser(conflict_resolution=ConflictResolution.ALWAYS_MERGE)

0 commit comments

Comments
 (0)