Skip to content

Commit

Permalink
build: drop python3.8, introduce 3.13. Update workflows to use hatch
Browse files Browse the repository at this point in the history
  • Loading branch information
KarolJagodzinski committed Feb 17, 2025
1 parent 3eeb06a commit a514e4e
Show file tree
Hide file tree
Showing 11 changed files with 163 additions and 149 deletions.
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3eeb06a168afc7ae37702db089c3faa2539ab652 # style: update codebase for Python 3.8 deprecation and Hatch configurationq
20 changes: 11 additions & 9 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,27 @@ jobs:
fail-fast: false
max-parallel: 1
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v3
- name: Checkout source code
uses: actions/checkout@v4
with:
ref: main

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install -e .[asgi-file-uploads,tracing,telemetry,test,dev]

- name: Install Hatch
uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc

- name: Benchmark
run: |
pytest benchmark --benchmark-storage=file://benchmark/results --benchmark-autosave
hatch test benchmark --benchmark-storage=file://benchmark/results --benchmark-autosave
cd benchmark && python rotate_results.py "${{ matrix.python-version }}"
- name: Commit
run: |
git config user.name "pytest-benchmark"
Expand Down
76 changes: 38 additions & 38 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,55 +10,55 @@ on:

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Hatch
uses: pypa/hatch@install
- name: Pytest
run: hatch test -c -py ${{ matrix.python-version }}
- uses: codecov/codecov-action@v3
- name: Pylint
run: hatch run pylint --py-version=3.8 ariadne tests
- name: mypy
run: hatch run mypy ariadne tests_mypy --ignore-missing-imports --check-untyped-defs
- name: black
run: hatch run black -t py38 --check .
- name: Benchmark
run: |
hatch run pytest benchmark --benchmark-storage=file://benchmark/results --benchmark-compare
- name: Checkout source code
uses: actions/checkout@v4

integration:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Hatch
uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc

- name: Run static analysis
run: hatch fmt --check

- name: Run type checking
run: hatch run types:check

- name: Run tests
run: hatch test -c -py ${{ matrix.python-version }}

- name: Benchmark
run: hatch test benchmark --benchmark-storage=file://benchmark/results --benchmark-compare

integration:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
library: ["fastapi", "starlette", "flask"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
env: ["test-integration-fastapi", "test-integration-starlette", "test-integration-flask"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install -r tests_integrations/${{ matrix.library }}/requirements.txt
pip install -e .[asgi-file-uploads,tracing,telemetry,test,dev]
- name: Pytest
run: |
pytest tests_integrations/${{ matrix.library }}
- name: Checkout source code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Hatch
uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc

- name: Run integration tests for ${{ matrix.env }}
run: hatch run ${{ matrix.env }}:test
3 changes: 2 additions & 1 deletion ariadne/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
)
from .graphql import graphql, graphql_sync, subscribe
from .inputs import InputType
from .interfaces import InterfaceType, type_implements_interface
from .interfaces import InterfaceType
from .load_schema import load_schema_from_path
from .objects import MutationType, ObjectType, QueryType
from .resolvers import (
Expand All @@ -35,6 +35,7 @@
convert_camel_case_to_snake,
convert_kwargs_to_snake_case,
gql,
type_implements_interface,
unwrap_graphql_error,
)

Expand Down
143 changes: 111 additions & 32 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ build-backend = "hatchling.build"

[project]
name = "ariadne"
version = "0.25.2"
requires-python = ">= 3.9"
version = "1.0.0"
description = "Ariadne is a Python library for implementing GraphQL servers."
authors = [{ name = "Mirumee Software", email = "[email protected]" }]
readme = "README.md"
Expand All @@ -15,11 +16,11 @@ classifiers = [
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Software Development :: Libraries :: Python Modules",
]
dependencies = [
Expand All @@ -29,7 +30,8 @@ dependencies = [
]

[project.optional-dependencies]
dev = ["black<25", "mypy", "pylint"]
dev = ["ipdb"]
types = ["mypy>=1.0.0"]
test = [
"pytest",
"pytest-asyncio",
Expand All @@ -46,9 +48,6 @@ test = [
"aiodataloader",
"graphql-sync-dataloaders;python_version>\"3.7\"",
]
asgi-file-uploads = ["python-multipart>=0.0.5"]
tracing = ["opentracing"]
telemetry = ["opentelemetry-api"]

[project.urls]
"Homepage" = "https://ariadnegraphql.org/"
Expand All @@ -66,51 +65,131 @@ include = [
]
exclude = [
"tests",
"tests_mypy",
"tests_integrations",
]

# Environment configuration

## Default environment

[tool.hatch.envs.default]
features = ["dev", "test"]
features = ["dev", "types"]

[tool.hatch.envs.default.scripts]
test = "coverage run -m pytest"
check = [
"pylint --py-version=3.8 ariadne tests",
"mypy ariadne tests_mypy --ignore-missing-imports --check-untyped-defs",
"black --check .",
"hatch fmt",
"hatch test -a -p",
"hatch test --cover",
"hatch run types:check",
]

## Types environment

[tool.hatch.envs.types.scripts]
check = "mypy --install-types --non-interactive"

## Test environments

[tool.hatch.envs.hatch-test]
features = ["dev", "test"]
features = ["test"]
extra-args = []


## Integration tests FastAPI environment
[tool.hatch.envs.test-integration-fastapi]
features = ["test"]
extra-dependencies = ["fastapi"]
scripts.test = "pytest tests_integrations/fastapi"


## Integration tests Flask environment
[tool.hatch.envs.test-integration-flask]
features = ["test"]
extra-dependencies = ["flask"]
scripts.test = "pytest tests_integrations/flask"

## Integration tests Starlette environment
[tool.hatch.envs.test-integration-starlette]
features = ["test"]
extra-dependencies = ["starlette"]
scripts.test = "pytest tests_integrations/starlette"

[tool.hatch.envs.test-integration.scripts]
test = "pip install {matrix:framework} && pytest tests_integrations/{matrix:framework}"

[[tool.hatch.envs.hatch-test.matrix]]
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]
python = ["3.9", "3.10", "3.11", "3.12", "3.13"]

[tool.black]
line-length = 88
target-version = ['py38']
include = '\.pyi?$'
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
| snapshots
)/
'''
# Tool configuration

## Pytest configuration

[tool.pytest.ini_options]
asyncio_mode = "strict"
asyncio_default_fixture_loop_scope = "function"
testpaths = ["tests"]

## Types configuration

[tool.mypy]
python_version = "3.9"
files = ["ariadne", "tests_mypy"]
check_untyped_defs = true
# disallow_untyped_defs = true
ignore_missing_imports = true
# warn_redundant_casts = true
# warn_unused_ignores = true
# disallow_any_generics = true
no_implicit_reexport = true
# strict = true
disable_error_code = ["import-untyped"]

## Coverage configuration

[tool.coverage.run]
source = ["ariadne", "tests"]

[tool.coverage.report]
exclude_also = [
"def __repr__",
"if self.debug:",
"if settings.DEBUG",
"raise AssertionError",
"raise NotImplementedError",
"if 0:",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
"class .*\\bProtocol\\):",
"@(abc\\.)?abstractmethod",
]
omit = ["*/__about__.py", "*/__main__.py", "*/cli/__init__.py"]
fail_under = 90

## Ruff configuration

[tool.ruff]
line-length = 88
target-version = "py39"

[tool.ruff.format]
docstring-code-format = true
docstring-code-line-length = 99

[tool.ruff.lint]
select = ["E", "F", "G", "I", "N", "Q", "UP", "C90", "T20", "TID"]
ignore = ["TID252"]
task-tags = ["NOTE", "TODO", "FIXME", "HACK", "XXX"]

[tool.ruff.lint.pycodestyle]
ignore-overlong-task-comments = true

[tool.ruff.lint.mccabe]
max-complexity = 15

[tool.ruff.lint.isort]
known-first-party = ["ariadne"]

[tool.ruff.lint.flake8-pytest-style]
fixture-parentheses = false
mark-parentheses = false
1 change: 0 additions & 1 deletion tests_integrations/fastapi/requirements.in

This file was deleted.

30 changes: 0 additions & 30 deletions tests_integrations/fastapi/requirements.txt

This file was deleted.

1 change: 0 additions & 1 deletion tests_integrations/flask/requirements.in

This file was deleted.

Loading

0 comments on commit a514e4e

Please sign in to comment.