Skip to content

Commit 2df0bcb

Browse files
chore: Move to Python 3.13 / Poetry 2.2 + Speedup CI builds
1 parent e98f851 commit 2df0bcb

13 files changed

Lines changed: 296 additions & 260 deletions

File tree

.config/mise/config.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
# and consider this toml file as the only source of truth
44
# Cf: https://mise.jdx.dev/configuration.html#idiomatic-version-files
55
legacy_version_file = false
6-
python.compile = true
76

87
[tools]
9-
python = "3.12"
10-
poetry = "1.8"
8+
python = "3.13"
9+
poetry = "2.2"
1110

1211
[env]
1312
_.file = '.env'

.devcontainer/devcontainer.json

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

.dockerignore

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

.github/workflows/pullrequest-push.yml

Lines changed: 32 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -10,91 +10,38 @@ on:
1010
- 'README.md'
1111
- 'catalog-info.yaml'
1212

13-
jobs:
14-
build:
15-
uses: ZeroGachis/.github/.github/workflows/build-image.yml@v4
16-
permissions:
17-
contents: read
18-
security-events: write
19-
actions: read
20-
id-token: write
21-
packages: write
22-
pull-requests: write
23-
checks: write
24-
with:
25-
image_name: magicparse
26-
dockerfile_context: .
27-
vault_url: ${{ vars.PULLREQUEST_VAULT_URL }}
28-
vault_github_actions_role: ${{ vars.VAULT_GITHUB_ACTIONS_ROLE }}
29-
regitry_url: ghcr.io
30-
secrets: inherit
3113

32-
static-metrics:
33-
needs:
34-
[
35-
build,
36-
]
37-
uses: ZeroGachis/.github/.github/workflows/run-docker.yml@v4
38-
permissions:
39-
contents: read
40-
id-token: write
41-
packages: read
42-
actions: write
43-
checks: write
44-
with:
45-
image_url: ${{ needs.build.outputs.image-url }}
46-
workdir: /app
47-
vault_enabled: false
48-
tailscale_enabled: false
49-
run_command: |
50-
poetry install --no-interaction --no-ansi --no-root --only dev
51-
ruff check --diff ./
52-
ruff format --check --diff ./
53-
pyright
54-
secrets: inherit
14+
permissions:
15+
actions: read
16+
checks: write
17+
contents: read
18+
id-token: write
19+
packages: write
20+
pull-requests: write
21+
security-events: write
5522

56-
unit-tests:
57-
needs:
58-
[
59-
build,
60-
]
61-
uses: ZeroGachis/.github/.github/workflows/run-docker-with-db.yml@v4
62-
permissions:
63-
contents: read
64-
id-token: write
65-
packages: read
66-
actions: write
67-
checks: write
68-
with:
69-
image_url: ${{ needs.build.outputs.image-url }}
70-
workdir: /app
71-
run_command: |
72-
poetry install --no-interaction --no-ansi --no-root --only dev
73-
poetry run pytest --verbose --junit-xml reports/unit_tests_results.xml
74-
vault_enabled: false
75-
tailscale_enabled: false
76-
enable_test_report: true
77-
test_report_name: "UT Report"
78-
test_report_path: reports/unit_tests_results.xml
79-
test_report_format: java-junit
80-
secrets: inherit
8123

82-
destroy:
83-
if: always()
84-
needs:
85-
[
86-
build,
87-
unit-tests,
88-
static-metrics,
89-
]
90-
uses: ZeroGachis/.github/.github/workflows/delete-docker-image.yml@v4
91-
permissions:
92-
contents: read
93-
id-token: write
94-
packages: write
95-
with:
96-
image_name: magicparse
97-
image_version: ${{ needs.build.outputs.image-version }}
98-
vault_url: ${{ vars.PULLREQUEST_VAULT_URL }}
99-
vault_github_actions_role: ${{ vars.VAULT_GITHUB_ACTIONS_ROLE }}
100-
secrets: inherit
24+
jobs:
25+
static-analysis-and-tests:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v6
29+
- uses: jdx/mise-action@v3
30+
with:
31+
install: true
32+
install_args: python poetry
33+
cache: true
34+
- name: Install Python dependencies
35+
uses: ZeroGachis/.github/.github/actions/poetry-install@v5
36+
with:
37+
aws_account_id: ${{ vars.PULL_REQUEST_AWS_ACCOUNT_ID }}
38+
install_options: --with ci
39+
depends_on_private_packages: false
40+
- name: Run Linter
41+
run: poetry run ruff check --output-format=github
42+
- name: Run Formatter
43+
run: poetry run ruff format --check
44+
- name: Run Typechecker
45+
run: poetry run basedpyright
46+
- name: Run unit tests
47+
run: poetry run pytest -p pytest_github_actions_annotate_failures

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ jobs:
2727
packages: read
2828
id-token: write
2929
with:
30-
python_version: "3.11"
30+
python_version: "3.13"
3131
environment_name: main

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ repos:
1313
entry: poetry run ruff format
1414
language: system
1515
types: [file, python]
16-
- id: pyright
17-
name: Pyright
18-
entry: poetry run pyright
16+
- id: typechecker
17+
name: typechecker
18+
entry: poetry run basedpyright
1919
language: system
2020
types: [file, python]

Dockerfile

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

docker-compose.yml

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

magicparse/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from collections.abc import Sequence
1+
from collections.abc import Iterable, Sequence
22
from io import BytesIO
33

44
from .schema import (
@@ -16,7 +16,7 @@
1616
)
1717
from .transform import Transform
1818
from .type_converters import TypeConverter, builtins as builtins_type_converters
19-
from typing import Any, Iterable
19+
from typing import Any
2020
from .validators import Validator, builtins as builtins_validators
2121

2222

magicparse/schema.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import codecs
22
from abc import ABC, abstractmethod
3+
from collections.abc import Iterable, Iterator
34
import csv
45
from dataclasses import dataclass
56

67
from magicparse.transform import SkipRow
78
from .fields import Field, ComputedField
89
from io import BytesIO
9-
from typing import Any, Dict, Iterator, List, Union, Iterable
10+
from typing import Any
1011

1112

1213
@dataclass(frozen=True, slots=True)
@@ -28,11 +29,11 @@ class RowFailed:
2829

2930

3031
class Schema(ABC):
31-
fields: List[Field]
32+
fields: list[Field]
3233
encoding: str
3334
has_headers: bool
3435

35-
def __init__(self, options: Dict[str, Any]) -> None:
36+
def __init__(self, options: dict[str, Any]) -> None:
3637
self.fields = [Field.build(item) for item in options["fields"]]
3738
self.computed_fields = [ComputedField.build(item) for item in options.get("computed-fields", [])]
3839

@@ -64,10 +65,10 @@ def register(cls, schema: type["Schema"]) -> None:
6465

6566
cls.registry[schema.key()] = schema
6667

67-
def parse(self, data: Union[bytes, BytesIO]) -> list[RowParsed | RowSkipped | RowFailed]:
68+
def parse(self, data: bytes | BytesIO) -> list[RowParsed | RowSkipped | RowFailed]:
6869
return list(self.stream_parse(data))
6970

70-
def stream_parse(self, data: Union[bytes, BytesIO]) -> Iterable[RowParsed | RowSkipped | RowFailed]:
71+
def stream_parse(self, data: bytes | BytesIO) -> Iterable[RowParsed | RowSkipped | RowFailed]:
7172
if isinstance(data, bytes):
7273
stream = BytesIO(data)
7374
else:
@@ -128,7 +129,7 @@ def process_fields(
128129

129130

130131
class CsvSchema(Schema):
131-
def __init__(self, options: Dict[str, Any]) -> None:
132+
def __init__(self, options: dict[str, Any]) -> None:
132133
super().__init__(options)
133134
self.delimiter = options.get("delimiter", ",")
134135
self.quotechar = options.get("quotechar", None)

0 commit comments

Comments
 (0)