Skip to content

Commit f4afb02

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents f15a21f + 7648acf commit f4afb02

File tree

91 files changed

+554
-308
lines changed

Some content is hidden

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

91 files changed

+554
-308
lines changed

.git-blame-ignore-revs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ba1c3bb3f0a1c9e85a8bb23012754ddc210e6567 # style: ruff linter/formatter migration

.github/workflows/build.yml

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Build
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
7+
env:
8+
PYTHONUNBUFFERED: "1"
9+
FORCE_COLOR: "1"
10+
11+
jobs:
12+
test:
13+
uses: ./.github/workflows/test.yml
14+
permissions:
15+
contents: read
16+
build:
17+
name: Build distribution 📦
18+
runs-on: ubuntu-latest
19+
needs:
20+
- test
21+
steps:
22+
- name: Checkout source code
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Python 3.12
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version-file: pyproject.toml
29+
30+
- name: Install Hatch
31+
uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc
32+
33+
- name: Set package version from tag
34+
run: hatch version $(git describe --tags --always)
35+
36+
- name: Build package
37+
run: hatch build
38+
39+
- name: Store the distribution packages
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: python-package-distributions
43+
path: dist/
44+
45+
sign-release:
46+
name: >-
47+
Sign the Python 🐍 distribution 📦 with Sigstore
48+
needs:
49+
- build
50+
runs-on: ubuntu-latest
51+
permissions:
52+
id-token: write # IMPORTANT: mandatory for sigstore
53+
steps:
54+
- name: Download all the dists
55+
uses: actions/download-artifact@v4
56+
with:
57+
name: python-package-distributions
58+
path: dist/
59+
- name: Sign the dists with Sigstore
60+
uses: sigstore/[email protected]
61+
with:
62+
inputs: >-
63+
./dist/*.tar.gz
64+
./dist/*.whl
65+
- name: Store the signature files
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: python-package-distributions
69+
path: dist/
70+
overwrite: true

.github/workflows/prepare_release.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Prepare release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
workflow_call:
8+
workflow_dispatch:
9+
10+
env:
11+
PYTHONUNBUFFERED: "1"
12+
FORCE_COLOR: "1"
13+
14+
jobs:
15+
build:
16+
uses: ./.github/workflows/build.yml
17+
permissions:
18+
contents: read
19+
id-token: write # IMPORTANT: mandatory for sigstore in build.yml
20+
21+
create-release:
22+
needs:
23+
- build
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Download all the dists
27+
uses: actions/download-artifact@v4
28+
with:
29+
name: python-package-distributions
30+
path: dist/
31+
- name: Release
32+
id: create-draft-release
33+
uses: softprops/action-gh-release@v2
34+
with:
35+
files: |
36+
./dist/*
37+
draft: true
38+
- name: Summary
39+
run: |
40+
echo "# Release summary" >> $GITHUB_STEP_SUMMARY
41+
echo "Url: ${{ steps.create-draft-release.outputs.url }}" >> $GITHUB_STEP_SUMMARY
42+
echo "You can now publish the release on GitHub" >> $GITHUB_STEP_SUMMARY

.github/workflows/publish.yml

+33-26
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,42 @@
1-
name: Publish on PyPI
1+
name: Publish
22

33
on:
44
release:
55
types:
66
- published
7+
workflow_call:
8+
workflow_dispatch:
9+
10+
env:
11+
PYTHONUNBUFFERED: "1"
12+
FORCE_COLOR: "1"
713

814
jobs:
9-
build-n-publish:
10-
name: Build and publish to PyPI
15+
publish-to-pypi:
16+
name: >-
17+
Publish Python 🐍 distribution 📦 to PyPI
18+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
1119
runs-on: ubuntu-latest
20+
environment:
21+
name: pypi
22+
url: https://pypi.org/p/ariadne-codegen
23+
permissions:
24+
# IMPORTANT: this permission is mandatory for trusted publishing
25+
id-token: write
26+
contents: read
27+
1228
steps:
13-
- uses: actions/checkout@master
14-
- name: Set up Python 3.10
15-
uses: actions/setup-python@v4
16-
with:
17-
python-version: "3.10"
18-
- name: Install pypa/build
19-
run: >-
20-
python -m
21-
pip install
22-
build
23-
--user
24-
- name: Build a binary wheel and a source tarball
25-
run: >-
26-
python -m build
27-
--sdist
28-
--wheel
29-
--outdir dist/
30-
.
31-
- name: Publish distribution to PyPI
32-
if: startsWith(github.ref, 'refs/tags')
33-
uses: pypa/gh-action-pypi-publish@release/v1
34-
with:
35-
password: ${{ secrets.PYPI_API_TOKEN }}
29+
- name: Download all the dists from the release
30+
env:
31+
GITHUB_TOKEN: ${{ github.token }}
32+
run: >-
33+
gh release download
34+
'${{ github.ref_name }}'
35+
-p '*.whl'
36+
-p '*.tar.gz'
37+
--dir dist/
38+
--repo '${{ github.repository }}'
39+
- name: Publish package distributions to PyPI
40+
uses: pypa/gh-action-pypi-publish@release/v1
41+
with:
42+
skip-existing: true

.github/workflows/test.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
schedule:
9+
- cron: "0 7 * * 1,3"
10+
workflow_call:
11+
workflow_dispatch:
12+
13+
concurrency:
14+
group: ci-${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
env:
18+
PYTHONUNBUFFERED: "1"
19+
FORCE_COLOR: "1"
20+
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
28+
steps:
29+
- name: Checkout source code
30+
uses: actions/checkout@v4
31+
32+
- name: Set up Python ${{ matrix.python-version }}
33+
uses: actions/setup-python@v5
34+
with:
35+
python-version: ${{ matrix.python-version }}
36+
37+
- name: Install Hatch
38+
uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc
39+
40+
- name: Run static analysis
41+
run: hatch fmt --check
42+
43+
- name: Run type checking
44+
run: hatch run types:check
45+
46+
- name: Run tests
47+
run: hatch test -c -py ${{ matrix.python-version }}

.github/workflows/tests.yml

-50
This file was deleted.

CONTRIBUTING.md

+25-12
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,41 @@ You can use [GitHub issues](https://github.com/mirumee/ariadne-codegen/issues) t
1414

1515
## Development setup
1616

17-
Ariadne Code Generator is written to support Python 3.9, 3.10 and 3.11.
17+
Ariadne Code Generator is written to support Python 3.9, 3.10, 3.11, 3.12 and 3.13.
1818

19-
Codebase is formatted using [black](https://github.com/ambv/black) and [isort](https://github.com/PyCQA/isort), the contents of the `ariadne-codegen` package are annotated with types and validated using [mypy](http://mypy-lang.org/index.html). [Pylint](https://github.com/pylint-dev/pylint) is used to catch errors in code.
19+
We use [Hatch](https://github.com/pypa/hatch) for project management.
2020

21-
Tests are developed using [pytest](https://pytest.org/).
21+
The codebase is formatted using [ruff](https://github.com/astral-sh/ruff).
22+
To format the code, use the following command:
23+
```bash
24+
hatch fmt
25+
```
2226

23-
Dev requirements can be installed using Pip extras. For example, to install all dependencies for doing local development and running the tests, run `pip install -e .[subscriptions,dev]`.
27+
The contents of the `ariadne-codegen` package are annotated with types and validated using [mypy](http://mypy-lang.org/index.html). To run type checking with mypy, use:
28+
```bash
29+
hatch run types:check
30+
```
2431

25-
We require all changes to be done via pull requests, and to be approved by member-ranked users before merging.
2632

27-
All changes should pass these linter checks:
33+
Tests are developed using [pytest](https://pytest.org/) and are managed with Hatch.
34+
2835

36+
To run the tests, use:
2937
```bash
30-
pylint ariadne_codegen tests
31-
mypy ariadne_codegen --ignore-missing-imports
32-
mypy --strict tests/main/clients/*/expected_client
33-
mypy --strict tests/main/graphql_schemas/*/expected_schema.py
34-
black --check .
35-
isort . --check-only
38+
hatch test
3639
```
3740

3841

42+
To run all checks (formatting, type checking, and tests), you can use:
43+
```bash
44+
hatch run check
45+
```
46+
47+
We require all changes to be done via pull requests, and to be approved by member-ranked users before merging.
48+
49+
All changes should pass these linter checks.
50+
51+
3952
## Working on issues
4053

4154
We consider all issues which are not assigned to anybody as being available for contributors. The **[help wanted](https://github.com/mirumee/ariadne-codegen/labels/help%20wanted)** label is used to single out issues that we consider easier or higher priority on the list of things that we would like to see.

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BSD 3-Clause License
22

3-
Copyright (c) 2023, Mirumee Labs
3+
Copyright (c) 2025, Mirumee Labs
44
All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without

ariadne_codegen/__about__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "0.0.1.dev0" # This is overwritten by Hatch in CI/CD, don't change it.

ariadne_codegen/client_generators/client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ def _generate_operation_str_assign(
894894
value=generate_call(
895895
func=generate_name(self._gql_func_name),
896896
args=[
897-
[generate_constant(l + "\n") for l in operation_str.splitlines()]
897+
[generate_constant(l + "\n") for l in operation_str.splitlines()] # noqa: E741
898898
],
899899
),
900900
lineno=lineno,

ariadne_codegen/client_generators/comments.py

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212

1313
def get_comment(strategy: CommentsStrategy, source: Optional[str] = None) -> str:
14-
# pylint: disable=unused-argument
1514
def empty_comment_function(source: Optional[str] = None) -> str:
1615
return ""
1716

ariadne_codegen/client_generators/dependencies/async_base_client.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@
2929
from contextlib import asynccontextmanager
3030

3131
@asynccontextmanager # type: ignore
32-
async def ws_connect(*args, **kwargs): # pylint: disable=unused-argument
32+
async def ws_connect(*args, **kwargs):
3333
raise NotImplementedError("Subscriptions require 'websockets' package.")
34-
yield # pylint: disable=unreachable
34+
yield
3535

3636
ClientConnection = Any # type: ignore[misc,assignment,unused-ignore]
3737
Data = Any # type: ignore[misc,assignment,unused-ignore]
3838
Origin = Any # type: ignore[misc,assignment,unused-ignore]
3939

40-
def Subprotocol(*args, **kwargs): # type: ignore # pylint: disable=invalid-name
40+
def Subprotocol(*args, **kwargs): # type: ignore # noqa: N802, N803
4141
raise NotImplementedError("Subscriptions require 'websockets' package.")
4242

4343

0 commit comments

Comments
 (0)