Skip to content

Commit

Permalink
feat: Official support for Python 3.13 and drop support for Python 3.8 (
Browse files Browse the repository at this point in the history
  • Loading branch information
bellini666 authored Oct 17, 2024
1 parent f18a7c8 commit f9afbda
Show file tree
Hide file tree
Showing 65 changed files with 613 additions and 740 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,18 @@ jobs:
- 4.2.*
- 5.0.*
python-version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
mode:
- std
- geos
exclude:
# Django 5.0 only supports python 3.10+
- django-version: 5.0.*
python-version: '3.8'
- django-version: 5.0.*
python-version: '3.9'
python-version: "3.9"
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
4 changes: 1 addition & 3 deletions docs/guide/fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ All one-to-one, one-to-many, many-to-one and many-to-many relationship types are
The default resolver of `strawberry_django.fields()` resolves the relationship based on given type information.

```python title="types.py"
from typing import List

@strawberry_django.type(models.Fruit)
class Fruit:
id: auto
Expand All @@ -52,7 +50,7 @@ class Fruit:
class Color:
id: auto
name: auto
fruits: List[Fruit]
fruits: list[Fruit]
```

Note that all relations can naturally trigger the n+1 problem. To avoid that, you can either
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/mutations.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ from strawberry_django import mutations

@strawberry.type
class Mutation:
updateFruits: List[Fruit] = mutations.update(FruitPartialInput, filters=FruitFilter)
deleteFruits: List[Fruit] = mutations.delete(filters=FruitFilter)
updateFruits: list[Fruit] = mutations.update(FruitPartialInput, filters=FruitFilter)
deleteFruits: list[Fruit] = mutations.delete(filters=FruitFilter)

schema = strawberry.Schema(mutation=Mutation)
```
2 changes: 1 addition & 1 deletion docs/guide/optimizer.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class SongType:
@strawberry.type
class Query:
artist: Artist = strawberry_django.field()
songs: List[SongType] = strawberry_django.field()
songs: list[SongType] = strawberry_django.field()
```

Querying for `artist` and `songs` like this:
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/relay.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Query:

# Option 3: You can manually create resolver by your method manually.
@strawberry_django.connection(ListConnectionWithTotalCount[FruitType])
def fruit_with_custom_resolver(self) -> List[SomeModel]:
def fruit_with_custom_resolver(self) -> list[SomeModel]:
return Fruit.objects.all()
```

Expand Down
6 changes: 2 additions & 4 deletions docs/guide/resolvers.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ in `sync_to_async` when running async.
```python title="types.py"
import strawberry_django
from strawberry import auto
from typing import List
from . import models

@strawberry_django.type(models.Color)
Expand All @@ -25,7 +24,7 @@ class Color:
name: auto

@strawberry_django.field
def fruits(self) -> List[Fruit]:
def fruits(self) -> list[Fruit]:
return self.fruits.objects.filter(...)
```

Expand All @@ -36,7 +35,6 @@ Async resolvers can be used when running using ASGI.
```python title="types.py"
import strawberry_django
from strawberry import auto
from typing import List
from . import models
from asgiref.sync import sync_to_async

Expand All @@ -46,7 +44,7 @@ class Color:
name: auto

@strawberry_django.field
async def fruits(self) -> List[Fruit]:
async def fruits(self) -> list[Fruit]:
return sync_to_async(list)(self.fruits.objects.filter(...))
```

Expand Down
9 changes: 4 additions & 5 deletions docs/guide/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ More information about that can be read from [resolvers](resolvers.md) page.
import strawberry_django

from strawberry import auto
from typing import List

@strawberry_django.type(models.Fruit)
class Fruit:
Expand All @@ -32,7 +31,7 @@ class Fruit:
class Color:
id: auto
name: auto
fruits: List[Fruit]
fruits: list[Fruit]
```

## Input types
Expand All @@ -56,21 +55,21 @@ Non-`auto` type annotations will be respected—and therefore required—unless
```python title="types.py"
@strawberry_django.input(models.Color, partial=True)
class FruitPartialInput(FruitInput):
color: List["ColorPartialInput"]
color: list["ColorPartialInput"]

# Auto fields are optional
@strawberry_django.input(models.Color, partial=True)
class ColorPartialInput:
id: auto
name: auto
fruits: List[FruitPartialInput]
fruits: list[FruitPartialInput]

# Alternate input; "name" field will be required
@strawberry_django.input(models.Color, partial=True)
class ColorNameRequiredPartialInput:
id: auto
name: str
fruits: List[FruitPartialInput]
fruits: list[FruitPartialInput]
```

## Types from Django models
Expand Down
18 changes: 8 additions & 10 deletions examples/django/app/schema.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import List

import strawberry

import strawberry_django
Expand All @@ -20,23 +18,23 @@
@strawberry.type
class Query:
fruit: Fruit = strawberry_django.field()
fruits: List[Fruit] = strawberry_django.field()
fruits: list[Fruit] = strawberry_django.field()

color: Color = strawberry_django.field()
colors: List[Color] = strawberry_django.field()
colors: list[Color] = strawberry_django.field()


@strawberry.type
class Mutation:
create_fruit: Fruit = mutations.create(FruitInput)
create_fruits: List[Fruit] = mutations.create(FruitInput)
update_fruits: List[Fruit] = mutations.update(FruitPartialInput)
delete_fruits: List[Fruit] = mutations.delete()
create_fruits: list[Fruit] = mutations.create(FruitInput)
update_fruits: list[Fruit] = mutations.update(FruitPartialInput)
delete_fruits: list[Fruit] = mutations.delete()

create_color: Color = mutations.create(ColorInput)
create_colors: List[Color] = mutations.create(ColorInput)
update_colors: List[Color] = mutations.update(ColorPartialInput)
delete_colors: List[Color] = mutations.delete()
create_colors: list[Color] = mutations.create(ColorInput)
update_colors: list[Color] = mutations.update(ColorPartialInput)
delete_colors: list[Color] = mutations.delete()

register: User = auth.register(UserInput)

Expand Down
4 changes: 2 additions & 2 deletions examples/django/app/types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional
from typing import Optional

from strawberry import auto

Expand Down Expand Up @@ -76,7 +76,7 @@ class Fruit:
class Color:
id: auto
name: auto
fruits: List[Fruit]
fruits: list[Fruit]


@strawberry_django.type(get_user_model())
Expand Down
Loading

0 comments on commit f9afbda

Please # to comment.