Update blacken-docs and black to latest versions (#9802)

* Update blacken-docs and black to latest versions

* Include docs folder for blackend-docs

* Run blacken docs on docs folder

* Fix broken link on authentication page
This commit is contained in:
Bruno Alla 2025-10-21 15:19:47 +02:00 committed by GitHub
parent 5a6f2ae7c9
commit 9b3d03a3d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 20 additions and 24 deletions

View File

@ -19,12 +19,11 @@ repos:
additional_dependencies: additional_dependencies:
- flake8-tidy-imports - flake8-tidy-imports
- repo: https://github.com/adamchainz/blacken-docs - repo: https://github.com/adamchainz/blacken-docs
rev: 1.16.0 rev: 1.20.0
hooks: hooks:
- id: blacken-docs - id: blacken-docs
exclude: ^(?!docs).*$
additional_dependencies: additional_dependencies:
- black==23.1.0 - black==25.9.0
- repo: https://github.com/codespell-project/codespell - repo: https://github.com/codespell-project/codespell
# Configuration for codespell is in .codespellrc # Configuration for codespell is in .codespellrc
rev: v2.2.6 rev: v2.2.6

View File

@ -67,10 +67,11 @@ Install using `pip`...
pip install djangorestframework pip install djangorestframework
Add `'rest_framework'` to your `INSTALLED_APPS` setting. Add `'rest_framework'` to your `INSTALLED_APPS` setting.
```python ```python
INSTALLED_APPS = [ INSTALLED_APPS = [
... # ...
'rest_framework', "rest_framework",
] ]
``` ```
@ -99,7 +100,7 @@ from rest_framework import routers, serializers, viewsets
class UserSerializer(serializers.HyperlinkedModelSerializer): class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta: class Meta:
model = User model = User
fields = ['url', 'username', 'email', 'is_staff'] fields = ["url", "username", "email", "is_staff"]
# ViewSets define the view behavior. # ViewSets define the view behavior.
@ -110,13 +111,13 @@ class UserViewSet(viewsets.ModelViewSet):
# Routers provide a way of automatically determining the URL conf. # Routers provide a way of automatically determining the URL conf.
router = routers.DefaultRouter() router = routers.DefaultRouter()
router.register(r'users', UserViewSet) router.register(r"users", UserViewSet)
# Wire up our API using automatic URL routing. # Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API. # Additionally, we include login URLs for the browsable API.
urlpatterns = [ urlpatterns = [
path('', include(router.urls)), path("", include(router.urls)),
path('api-auth/', include('rest_framework.urls', namespace='rest_framework')), path("api-auth/", include("rest_framework.urls", namespace="rest_framework")),
] ]
``` ```
@ -126,15 +127,15 @@ Add the following to your `settings.py` module:
```python ```python
INSTALLED_APPS = [ INSTALLED_APPS = [
... # Make sure to include the default installed apps here. # ... make sure to include the default installed apps here.
'rest_framework', "rest_framework",
] ]
REST_FRAMEWORK = { REST_FRAMEWORK = {
# Use Django's standard `django.contrib.auth` permissions, # Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users. # or allow read-only access for unauthenticated users.
'DEFAULT_PERMISSION_CLASSES': [ "DEFAULT_PERMISSION_CLASSES": [
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly', "rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly",
] ]
} }
``` ```

View File

@ -454,7 +454,7 @@ There are currently two forks of this project.
More information can be found in the [Documentation](https://django-rest-durin.readthedocs.io/en/latest/index.html). More information can be found in the [Documentation](https://django-rest-durin.readthedocs.io/en/latest/index.html).
## django-pyoidc ## django-pyoidc
[dango-pyoidc][django_pyoidc] adds support for OpenID Connect (OIDC) authentication. This allows you to delegate user management to an Identity Provider, which can be used to implement Single-Sign-On (SSO). It provides support for most uses-cases, such as customizing how token info are mapped to user models, using OIDC audiences for access control, etc. [dango-pyoidc][django_pyoidc] adds support for OpenID Connect (OIDC) authentication. This allows you to delegate user management to an Identity Provider, which can be used to implement Single-Sign-On (SSO). It provides support for most uses-cases, such as customizing how token info are mapped to user models, using OIDC audiences for access control, etc.
@ -497,4 +497,4 @@ More information can be found in the [Documentation](https://django-pyoidc.readt
[django-rest-authemail]: https://github.com/celiao/django-rest-authemail [django-rest-authemail]: https://github.com/celiao/django-rest-authemail
[django-rest-durin]: https://github.com/eshaan7/django-rest-durin [django-rest-durin]: https://github.com/eshaan7/django-rest-durin
[login-required-middleware]: https://docs.djangoproject.com/en/stable/ref/middleware/#django.contrib.auth.middleware.LoginRequiredMiddleware [login-required-middleware]: https://docs.djangoproject.com/en/stable/ref/middleware/#django.contrib.auth.middleware.LoginRequiredMiddleware
[django-pyoidc] : https://github.com/makinacorpus/django_pyoidc [django-pyoidc]: https://github.com/makinacorpus/django_pyoidc

View File

@ -231,7 +231,7 @@ Using the example from the previous section:
Alternatively, you can use the `url_name` attribute set by the `@action` decorator. Alternatively, you can use the `url_name` attribute set by the `@action` decorator.
```pycon ```pycon
>>> view.reverse_action(view.set_password.url_name, args=['1']) >>> view.reverse_action(view.set_password.url_name, args=["1"])
'http://localhost:8000/api/users/1/set_password' 'http://localhost:8000/api/users/1/set_password'
``` ```

View File

@ -50,11 +50,9 @@ class DocStringExampleListView(APIView):
permission_classes = [permissions.IsAuthenticatedOrReadOnly] permission_classes = [permissions.IsAuthenticatedOrReadOnly]
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs): ...
...
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs): ...
...
``` ```
## Validator / Default Context ## Validator / Default Context
@ -76,8 +74,7 @@ Validator implementations will look like this:
class CustomValidator: class CustomValidator:
requires_context = True requires_context = True
def __call__(self, value, serializer_field): def __call__(self, value, serializer_field): ...
...
``` ```
Default implementations will look like this: Default implementations will look like this:
@ -86,8 +83,7 @@ Default implementations will look like this:
class CustomDefault: class CustomDefault:
requires_context = True requires_context = True
def __call__(self, serializer_field): def __call__(self, serializer_field): ...
...
``` ```
--- ---