From 7b92efe9102b10f07daace1ad5bc0e6784cb9cd8 Mon Sep 17 00:00:00 2001 From: pulpbot Date: Sun, 26 Jul 2026 17:48:24 +0000 Subject: [PATCH] Update CI files --- pyproject.toml | 1 + .../guides/authentication/01-overview.md | 10 +++++----- .../guides/authentication/03-webserver.md | 6 +++--- .../guides/authentication/04-keycloak.md | 18 ++++++++--------- staging_docs/admin/learn/settings.md | 4 ++-- .../dev/learn/architecture/rest-api.md | 17 ++++++++-------- .../concepts/domains/domains_compatibility.md | 2 ++ .../learn/triage-needed!/concepts/index.md | 20 +++++++------------ .../rbac/adding_automatic_permissions.md | 5 ++--- .../concepts/rbac/permissions.md | 5 +---- .../concepts/rbac/queryset_scoping.md | 8 ++++---- .../concepts/subclassing/models.md | 13 ++++++------ .../concepts/subclassing/serializers.md | 5 +++-- .../concepts/subclassing/viewsets.md | 20 ++++++++----------- .../concepts/tasks/add-remove.md | 7 +++---- .../topics/content-protection.md | 6 +++--- .../triage-needed!/topics/how-plugins-work.md | 6 +++--- .../triage-needed!/topics/how-to-doc-api.md | 5 ++--- .../reference/api-reference/content-app.md | 5 ++--- 19 files changed, 76 insertions(+), 87 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 115bec6c267..7a980f532d9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -172,6 +172,7 @@ extend-exclude = [ [tool.ruff.lint] # This section is managed by the plugin template. Do not edit manually. +select = ["E4", "E7", "E9", "F"] extend-select = [ "I", "INT", diff --git a/staging_docs/admin/guides/authentication/01-overview.md b/staging_docs/admin/guides/authentication/01-overview.md index cc7c75d1620..a6fd9492f15 100644 --- a/staging_docs/admin/guides/authentication/01-overview.md +++ b/staging_docs/admin/guides/authentication/01-overview.md @@ -21,8 +21,8 @@ passwords against. By default it is set to: ```python AUTHENTICATION_BACKENDS = [ - 'django.contrib.auth.backends.ModelBackend', # Django's users, groups, and permissions - 'pulpcore.backends.ObjectRolePermissionBackend' # Pulp's RBAC object and model permissions + "django.contrib.auth.backends.ModelBackend", # Django's users, groups, and permissions + "pulpcore.backends.ObjectRolePermissionBackend", # Pulp's RBAC object and model permissions ] ``` @@ -31,9 +31,9 @@ Django Rest Framework defines the source usernames and passwords come from with ```python REST_FRAMEWORK = { - 'DEFAULT_AUTHENTICATION_CLASSES': [ - 'rest_framework.authentication.SessionAuthentication', # Session Auth - 'rest_framework.authentication.BasicAuthentication' # Basic Auth + "DEFAULT_AUTHENTICATION_CLASSES": [ + "rest_framework.authentication.SessionAuthentication", # Session Auth + "rest_framework.authentication.BasicAuthentication", # Basic Auth ] } ``` diff --git a/staging_docs/admin/guides/authentication/03-webserver.md b/staging_docs/admin/guides/authentication/03-webserver.md index 321e1c7508e..a29599f9ec6 100644 --- a/staging_docs/admin/guides/authentication/03-webserver.md +++ b/staging_docs/admin/guides/authentication/03-webserver.md @@ -30,9 +30,9 @@ Specify how to receive the username from the webserver. Do this by specifying to `DEFAULT_AUTHENTICATION_CLASSES`. For example, consider this example: ```python - REST_FRAMEWORK['DEFAULT_AUTHENTICATION_CLASSES'] = ( - 'rest_framework.authentication.SessionAuthentication', - 'pulpcore.app.authentication.PulpRemoteUserAuthentication' + REST_FRAMEWORK["DEFAULT_AUTHENTICATION_CLASSES"] = ( + "rest_framework.authentication.SessionAuthentication", + "pulpcore.app.authentication.PulpRemoteUserAuthentication", ) ``` diff --git a/staging_docs/admin/guides/authentication/04-keycloak.md b/staging_docs/admin/guides/authentication/04-keycloak.md index 2208cf8d74f..665ec024b60 100644 --- a/staging_docs/admin/guides/authentication/04-keycloak.md +++ b/staging_docs/admin/guides/authentication/04-keycloak.md @@ -75,15 +75,15 @@ Define the authentication pipeline for data that will be associated with users: ```python title="settings.py" SOCIAL_AUTH_PIPELINE = ( - 'social_core.pipeline.social_auth.social_details', - 'social_core.pipeline.social_auth.social_uid', - 'social_core.pipeline.social_auth.social_user', - 'social_core.pipeline.user.get_username', - 'social_core.pipeline.social_auth.associate_by_email', - 'social_core.pipeline.user.create_user', - 'social_core.pipeline.social_auth.associate_user', - 'social_core.pipeline.social_auth.load_extra_data', - 'social_core.pipeline.user.user_details', + "social_core.pipeline.social_auth.social_details", + "social_core.pipeline.social_auth.social_uid", + "social_core.pipeline.social_auth.social_user", + "social_core.pipeline.user.get_username", + "social_core.pipeline.social_auth.associate_by_email", + "social_core.pipeline.user.create_user", + "social_core.pipeline.social_auth.associate_user", + "social_core.pipeline.social_auth.load_extra_data", + "social_core.pipeline.user.user_details", ) ``` diff --git a/staging_docs/admin/learn/settings.md b/staging_docs/admin/learn/settings.md index 84efeae6eb3..3b4c6ae6c8e 100644 --- a/staging_docs/admin/learn/settings.md +++ b/staging_docs/admin/learn/settings.md @@ -29,8 +29,8 @@ The following code snippet can be used to generate a random SECRET_KEY. ```python linenums="1" import random -chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)' -print(''.join(random.choice(chars) for i in range(50))) +chars = "abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)" +print("".join(random.choice(chars) for i in range(50))) ``` ### DB_ENCRYPTION_KEY diff --git a/staging_docs/dev/learn/architecture/rest-api.md b/staging_docs/dev/learn/architecture/rest-api.md index 2797f0978f6..183fdf7a98e 100644 --- a/staging_docs/dev/learn/architecture/rest-api.md +++ b/staging_docs/dev/learn/architecture/rest-api.md @@ -285,7 +285,7 @@ This is what the ViewSet should look like: class RepositoryViewSet(viewsets.ModelViewSet): queryset = models.Repository.objects.all() serializer_class = serializers.RepositorySerializer - filterset_fields = ('name',) + filterset_fields = ("name",) ``` #### FilterSet @@ -303,7 +303,8 @@ class RepositoryFilter(filters.FilterSet): class Meta: model = models.Repository - fields = ['name'] + fields = ["name"] + class RepositoryViewSet(viewsets.ModelViewSet): queryset = models.Repository.objects.all() @@ -328,11 +329,11 @@ Simply define any filters in the `FilterSet` and then include them in `fields` i ```python class RepositoryFilter(filters.FilterSet): - name_contains = django_filters.filters.CharFilter(field_name='name', lookup_expr='contains') + name_contains = django_filters.filters.CharFilter(field_name="name", lookup_expr="contains") class Meta: model = models.Repository - fields = ['name_contains'] + fields = ["name_contains"] ``` #### Custom Filters @@ -348,16 +349,16 @@ http 'http://192.168.121.134:24817/pulp/api/v3/repositories/?name_in_list=singin ``` ```python -class CharInFilter(django_filters.filters.BaseInFilter, - django_filters.filters.CharFilter): +class CharInFilter(django_filters.filters.BaseInFilter, django_filters.filters.CharFilter): pass + class RepositoryFilter(filters.FilterSet): - name_in_list = CharInFilter(name='name', lookup_expr='in') + name_in_list = CharInFilter(name="name", lookup_expr="in") class Meta: model = models.Repository - fields = ['name_in_list'] + fields = ["name_in_list"] ``` !!! note diff --git a/staging_docs/dev/learn/triage-needed!/concepts/domains/domains_compatibility.md b/staging_docs/dev/learn/triage-needed!/concepts/domains/domains_compatibility.md index cd245fe740a..9bd9f46944b 100644 --- a/staging_docs/dev/learn/triage-needed!/concepts/domains/domains_compatibility.md +++ b/staging_docs/dev/learn/triage-needed!/concepts/domains/domains_compatibility.md @@ -20,6 +20,7 @@ See the code below for an example: ```python from pulpcore.plugin.util import get_domain_pk + class FileContent(Content): ... _pulp_domain = models.ForeignKey("core.Domain", default=get_domain_pk, on_delete=models.PROTECT) @@ -59,6 +60,7 @@ from pulpcore.plugin.models import Task from pulpcore.plugin.util import get_domain from .models import CustomModel + def custom_task(custom_property): # How to get the current domain for this task domain = Task.current().pulp_domain diff --git a/staging_docs/dev/learn/triage-needed!/concepts/index.md b/staging_docs/dev/learn/triage-needed!/concepts/index.md index 4b83fac063f..f111452c265 100644 --- a/staging_docs/dev/learn/triage-needed!/concepts/index.md +++ b/staging_docs/dev/learn/triage-needed!/concepts/index.md @@ -178,7 +178,7 @@ temp_file.save() # Example 2 - Validating the digest and saving a temporary file: temp_file = PulpTemporaryFile.init_and_validate( - my_file, expected_digests={'md5': '912ec803b2ce49e4a541068d495ab570'} + my_file, expected_digests={"md5": "912ec803b2ce49e4a541068d495ab570"} ) temp_file.save() @@ -259,18 +259,15 @@ GroupProgressReport needs to be updated. task_group = TaskGroup(description="Migration Sub-tasks") task_group.save() group_pr = GroupProgressReport( - message="Repo migration", - code="create.repo_version", - total=1, - done=0, - task_group=task_group) + message="Repo migration", code="create.repo_version", total=1, done=0, task_group=task_group +) group_pr.save() # When a task that will be executing certain work, which is part of a TaskGroup, it will look # for the TaskGroup it belongs to and find appropriate progress report by its code and will # update it accordingly. task_group = TaskGroup.current() -progress_repo = task_group.group_progress_reports.filter(code='create.repo_version') -progress_repo.update(done=F('done') + 1) +progress_repo = task_group.group_progress_reports.filter(code="create.repo_version") +progress_repo.update(done=F("done") + 1) # To avoid race conditions/cache invalidation issues, this pattern needs to be used so that # operations are performed directly inside the database: @@ -369,13 +366,10 @@ below so `dynaconf` can run your plugin's validators. See [dynaconf validator do ```python from dynaconf import Validator + def post(settings): """This hook is called by dynaconf after the settings are completely loaded""" - settings.validators.register( - Validator(...), - Validator(...), - ... - ) + settings.validators.register(Validator(...), Validator(...), ...) settings.validators.validate() ``` diff --git a/staging_docs/dev/learn/triage-needed!/concepts/rbac/adding_automatic_permissions.md b/staging_docs/dev/learn/triage-needed!/concepts/rbac/adding_automatic_permissions.md index 57e4e5c36c8..aa52c155fd6 100644 --- a/staging_docs/dev/learn/triage-needed!/concepts/rbac/adding_automatic_permissions.md +++ b/staging_docs/dev/learn/triage-needed!/concepts/rbac/adding_automatic_permissions.md @@ -74,8 +74,7 @@ To enable automatic permission creation for an object managed by an AccessPolicy use the `pulpcore.plugin.models.AutoAddObjPermsMixin`. See the example below as an example: ```python -class MyModel(BaseModel, AutoAddObjPermsMixin): - ... +class MyModel(BaseModel, AutoAddObjPermsMixin): ... ``` See the docstring below for more information on this mixin. @@ -124,13 +123,13 @@ the `function` are method names on the Model that need to be registered with ```python class MyModel(BaseModel, AutoAddObjPermsMixin): - def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.REGISTERED_CREATION_HOOKS["my_custom_callable"] = self.my_custom_callable def my_custom_callable(self, role, users, groups): from pulpcore.app.util import assign_role + for user in users: assign_role(role, user, self) # self is the object being assigned for group in groups: diff --git a/staging_docs/dev/learn/triage-needed!/concepts/rbac/permissions.md b/staging_docs/dev/learn/triage-needed!/concepts/rbac/permissions.md index 2e6f812b3bf..afa7ec3d041 100644 --- a/staging_docs/dev/learn/triage-needed!/concepts/rbac/permissions.md +++ b/staging_docs/dev/learn/triage-needed!/concepts/rbac/permissions.md @@ -56,14 +56,11 @@ Here's an example of adding a permission like this for `FileRepository`: ```python class FileRepository(Repository): - ... class Meta: ... - permissions = ( - ('modify_repo_content', 'Modify Repository Content'), - ) + permissions = (("modify_repo_content", "Modify Repository Content"),) ``` !!! note diff --git a/staging_docs/dev/learn/triage-needed!/concepts/rbac/queryset_scoping.md b/staging_docs/dev/learn/triage-needed!/concepts/rbac/queryset_scoping.md index 4a535f0f291..b9e534189c6 100644 --- a/staging_docs/dev/learn/triage-needed!/concepts/rbac/queryset_scoping.md +++ b/staging_docs/dev/learn/triage-needed!/concepts/rbac/queryset_scoping.md @@ -74,14 +74,14 @@ parameters can also be accepted by supplying them in a `parameters` section of t from pulpcore.plugin.viewsets import NamedModelViewSet from pulpcore.plugin.util import get_objects_for_user -class MyViewSet(NamedModelViewSet): +class MyViewSet(NamedModelViewSet): DEFAULT_ACCESS_POLICY = { # Statements omitted - "queryset_scoping" : { + "queryset_scoping": { # This entire field is editable by the user "function": "different_permission_scope", - "parameters": {"permission": "my.example_permission"} + "parameters": {"permission": "my.example_permission"}, } } @@ -100,8 +100,8 @@ provided by pulpcore. Here's an example: ```python from pulpcore.plugin.util import get_objects_for_user -class MyViewSet(rest_framework.viewsets.GenericViewSet): +class MyViewSet(rest_framework.viewsets.GenericViewSet): def get_queryset(self): qs = super().get_queryset() permission_name = "my.example_permission" diff --git a/staging_docs/dev/learn/triage-needed!/concepts/subclassing/models.md b/staging_docs/dev/learn/triage-needed!/concepts/subclassing/models.md index f206d48e735..24cb42327eb 100644 --- a/staging_docs/dev/learn/triage-needed!/concepts/subclassing/models.md +++ b/staging_docs/dev/learn/triage-needed!/concepts/subclassing/models.md @@ -34,7 +34,8 @@ class FileContent(Content): Fields: digest (str): The SHA256 HEX digest. """ - TYPE = 'file' + + TYPE = "file" digest = models.TextField(null=False) class Meta: @@ -75,13 +76,13 @@ class FileContent(Content): digest (str): The SHA256 HEX digest. """ - TYPE = 'file' + TYPE = "file" digest = models.TextField(null=False) class Meta: # Note the comma, this must be a tuple. - unique_together = ('digest',) + unique_together = ("digest",) default_related_name = "%(app_label)s_%(model_name)s" ``` @@ -99,7 +100,7 @@ class FileContent(Content): digest (str): The SHA256 HEX digest. """ - TYPE = 'file' + TYPE = "file" relative_path = models.TextField(null=False) digest = models.TextField(null=False) @@ -107,8 +108,8 @@ class FileContent(Content): class Meta: default_related_name = "%(app_label)s_%(model_name)s" unique_together = ( - 'relative_path', - 'digest', + "relative_path", + "digest", ) ``` diff --git a/staging_docs/dev/learn/triage-needed!/concepts/subclassing/serializers.md b/staging_docs/dev/learn/triage-needed!/concepts/subclassing/serializers.md index d7809d2fc61..b24cabdb028 100644 --- a/staging_docs/dev/learn/triage-needed!/concepts/subclassing/serializers.md +++ b/staging_docs/dev/learn/triage-needed!/concepts/subclassing/serializers.md @@ -29,9 +29,10 @@ class FileContentSerializer(SingleArtifactContentSerializer): help_text="Relative location of the file within the repository" ) + class Meta: - fields = SingleArtifactContentSerializer.Meta.fields + ('relative_path',) - model = FileContent + fields = SingleArtifactContentSerializer.Meta.fields + ("relative_path",) + model = FileContent ``` ### Help Text diff --git a/staging_docs/dev/learn/triage-needed!/concepts/subclassing/viewsets.md b/staging_docs/dev/learn/triage-needed!/concepts/subclassing/viewsets.md index 85ba2656671..2e4e11f4674 100644 --- a/staging_docs/dev/learn/triage-needed!/concepts/subclassing/viewsets.md +++ b/staging_docs/dev/learn/triage-needed!/concepts/subclassing/viewsets.md @@ -24,7 +24,7 @@ For example, a ContentViewSet for `app_label` "foobar" like this: ```python class PackageViewSet(ContentViewSet): - endpoint_name = 'packages' + endpoint_name = "packages" ``` The above example will create set of CRUD endpoints for Packages at @@ -37,9 +37,9 @@ In addition to the CRUD endpoints, a Viewset can also add a custom endpoint. For ```python class PackageViewSet(ContentViewSet): - endpoint_name = 'packages' + endpoint_name = "packages" - @decorators.detail_route(methods=('get',)) + @decorators.detail_route(methods=("get",)) def hello(self, request): return Response("Hey!") ``` @@ -68,7 +68,7 @@ a task. ```python # We recommend using POST for any endpoints that kick off task. -@detail_route(methods=('post',), serializer_class=RepositorySyncURLSerializer) +@detail_route(methods=("post",), serializer_class=RepositorySyncURLSerializer) # `pk` is a part of the URL def sync(self, request, pk): """ @@ -76,22 +76,18 @@ def sync(self, request, pk): The ``repository`` field has to be provided. """ remote = self.get_object() - serializer = RepositorySyncURLSerializer(data=request.data, context={'request': request}) + serializer = RepositorySyncURLSerializer(data=request.data, context={"request": request}) # This is how non-crud validation is accomplished serializer.is_valid(raise_exception=True) - repository = serializer.validated_data.get('repository') - mirror = serializer.validated_data.get('mirror', False) + repository = serializer.validated_data.get("repository") + mirror = serializer.validated_data.get("mirror", False) # This is how tasks are kicked off. result = dispatch( tasks.synchronize, exclusive_resources=[repository], shared_resources=[remote], - kwargs={ - 'remote_pk': remote.pk, - 'repository_pk': repository.pk, - 'mirror': mirror - } + kwargs={"remote_pk": remote.pk, "repository_pk": repository.pk, "mirror": mirror}, ) # Since tasks are asynchronous, we return a 202 return OperationPostponedResponse(result, request) diff --git a/staging_docs/dev/learn/triage-needed!/concepts/tasks/add-remove.md b/staging_docs/dev/learn/triage-needed!/concepts/tasks/add-remove.md index 1eae8985688..72b194d6227 100644 --- a/staging_docs/dev/learn/triage-needed!/concepts/tasks/add-remove.md +++ b/staging_docs/dev/learn/triage-needed!/concepts/tasks/add-remove.md @@ -16,10 +16,9 @@ working directory setup, and database cleanup after encountering failures. ```python with repository.new_version() as new_version: - - # add content manually - new_version.add_content(content) - new_version.remove_content(content) + # add content manually + new_version.add_content(content) + new_version.remove_content(content) ``` !!! warning diff --git a/staging_docs/dev/learn/triage-needed!/topics/content-protection.md b/staging_docs/dev/learn/triage-needed!/topics/content-protection.md index fa6831ad6e3..c85cc81d398 100644 --- a/staging_docs/dev/learn/triage-needed!/topics/content-protection.md +++ b/staging_docs/dev/learn/triage-needed!/topics/content-protection.md @@ -38,9 +38,9 @@ secret both authenticates the user and authorizes them for this Content. from django.db import models from pulpcore.plugin.models import ContentGuard -class SecretStringContentGuard(ContentGuard): - TYPE = 'secret_string' +class SecretStringContentGuard(ContentGuard): + TYPE = "secret_string" secret_string = models.FileField(max_length=255) @@ -56,7 +56,7 @@ class SecretStringContentGuard(ContentGuard): PermissionError: When the request cannot be authorized. """ ca = self.ca_certificate.read() - validator = Validator(ca.decode('utf8')) + validator = Validator(ca.decode("utf8")) validator(request) class Meta: diff --git a/staging_docs/dev/learn/triage-needed!/topics/how-plugins-work.md b/staging_docs/dev/learn/triage-needed!/topics/how-plugins-work.md index 7a9505a7dc4..03d35358bd3 100644 --- a/staging_docs/dev/learn/triage-needed!/topics/how-plugins-work.md +++ b/staging_docs/dev/learn/triage-needed!/topics/how-plugins-work.md @@ -37,9 +37,9 @@ plugin, by pointing the pulpcore.plugin entry point at it. If, for example, we s this: ```python -entry_points={ - 'pulpcore.plugin': [ - 'pulp_myplugin = pulp_myplugin:default_app_config', +entry_points = { + "pulpcore.plugin": [ + "pulp_myplugin = pulp_myplugin:default_app_config", ] } ``` diff --git a/staging_docs/dev/learn/triage-needed!/topics/how-to-doc-api.md b/staging_docs/dev/learn/triage-needed!/topics/how-to-doc-api.md index 5adfb46668f..6601d341a0c 100644 --- a/staging_docs/dev/learn/triage-needed!/topics/how-to-doc-api.md +++ b/staging_docs/dev/learn/triage-needed!/topics/how-to-doc-api.md @@ -17,13 +17,12 @@ Response status codes can be generated through the `Meta` class on the serialize ```python from rest_framework.status import HTTP_400_BAD_REQUEST + class SnippetSerializerV1(serializers.Serializer): title = serializers.CharField(required=False, allow_blank=True, max_length=100) class Meta: - error_status_codes = { - HTTP_400_BAD_REQUEST: 'Bad Request' - } + error_status_codes = {HTTP_400_BAD_REQUEST: "Bad Request"} ``` You may disable schema generation for a view by setting `schema` to `None`: diff --git a/staging_docs/reference/api-reference/content-app.md b/staging_docs/reference/api-reference/content-app.md index f83e2cd75aa..ee54ad0b8b5 100644 --- a/staging_docs/reference/api-reference/content-app.md +++ b/staging_docs/reference/api-reference/content-app.md @@ -28,8 +28,8 @@ provided by overriding the various methods of `Handler`, but here is the simples ```python from pulpcore.plugin.content import Handler -class MyHandler(Handler): +class MyHandler(Handler): pass ``` @@ -43,7 +43,7 @@ adding a custom route to it. Here's an example: ```python from pulpcore.content import app -app.add_routes([web.get(r'/my/custom/{somevar:.+}', MyHandler().stream_content)]) +app.add_routes([web.get(r"/my/custom/{somevar:.+}", MyHandler().stream_content)]) ``` Here is an example of [Container registering some custom routes](https://github.com/pulp/pulp_container/blob/master/pulp_container/app/content.py). @@ -60,7 +60,6 @@ from models import MyDistribution class MyHandler(Handler): - distribution_model = MyDistribution ```