Skip to content

Commit

Permalink
Add __all__ attribute to modules
Browse files Browse the repository at this point in the history
The reason for this is because mkdocstrings requires this declaration
to display imported members:

https://mkdocstrings.github.io/python/usage/configuration/general/?h=import#preload_modules

When we are using `__all__`, we could use star imports to avoid so much name
duplication.

Fixup: remove F401 when using __all__ and remove unecessary options
  • Loading branch information
pedro-psb committed Oct 15, 2024
1 parent 5c97b3c commit a5aceb5
Show file tree
Hide file tree
Showing 13 changed files with 265 additions and 20 deletions.
3 changes: 0 additions & 3 deletions docs/dev/reference/code-api/platform-api/app/auth.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# pulp.app.auth

::: pulpcore.app.authentication
options:
members: true
filters: ["!_*"]
3 changes: 0 additions & 3 deletions docs/dev/reference/code-api/platform-api/app/settings.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# pulp.app.settings

::: pulpcore.app.settings
options:
members: true
heading_level: 2
3 changes: 0 additions & 3 deletions docs/dev/reference/code-api/platform-api/constants.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# pulp.constants

::: pulpcore.constants
options:
members: true
heading_level: 2
2 changes: 0 additions & 2 deletions docs/dev/reference/code-api/plugins-api/stages.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ to make writing sync code easier. There are several parts to the API:
## Content Related Stages

::: pulpcore.plugin.stages.ContentSaver
options:
filters: ["!_pre_save", "!_post_save"]

::: pulpcore.plugin.stages.QueryExistingContents

Expand Down
69 changes: 69 additions & 0 deletions pulpcore/app/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,72 @@
OpenPGPUserAttribute,
OpenPGPUserID,
)

__all__ = [
"BaseModel",
"MasterModel",
"pulp_uuid",
"AccessPolicy",
"AutoAddObjPermsMixin",
"Group",
"Domain",
"AlternateContentSource",
"AlternateContentSourcePath",
"Artifact",
"AsciiArmoredDetachedSigningService",
"Content",
"ContentManager",
"ContentArtifact",
"PulpTemporaryFile",
"RemoteArtifact",
"SigningService",
"UnsupportedDigestValidationError",
"GenericRelationModel",
"Export",
"ExportedResource",
"Exporter",
"FilesystemExport",
"FilesystemExporter",
"PulpExport",
"PulpExporter",
"Import",
"Importer",
"PulpImport",
"PulpImporter",
"ContentGuard",
"Distribution",
"Publication",
"PublishedArtifact",
"PublishedMetadata",
"RBACContentGuard",
"CompositeContentGuard",
"ContentRedirectContentGuard",
"HeaderContentGuard",
"ArtifactDistribution",
"Remote",
"Repository",
"RepositoryContent",
"RepositoryVersion",
"RepositoryVersionContentDetails",
"ApiAppStatus",
"ContentAppStatus",
"CreatedResource",
"ProfileArtifact",
"Task",
"TaskGroup",
"TaskSchedule",
"Worker",
"SystemID",
"Upload",
"UploadChunk",
"GroupProgressReport",
"ProgressReport",
"UpstreamPulp",
"OpenPGPDistribution",
"OpenPGPKeyring",
"OpenPGPPublicKey",
"OpenPGPPublicSubkey",
"OpenPGPSignature",
"OpenPGPUserAttribute",
"OpenPGPUserID",
]
4 changes: 2 additions & 2 deletions pulpcore/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
Django settings for the Pulp Platform application
Never import this module directly, instead `from django.conf import settings`, see
https://docs.djangoproject.com/en/3.2/topics/settings/#using-settings-in-python-code
<https://docs.djangoproject.com/en/3.2/topics/settings/#using-settings-in-python-code>
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.2/ref/settings/
<https://docs.djangoproject.com/en/3.2/ref/settings/>
"""

import sys
Expand Down
13 changes: 12 additions & 1 deletion pulpcore/plugin/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pulpcore.exceptions import ( # noqa: F401
from pulpcore.exceptions import (
DigestValidationError,
InvalidSignatureError,
PulpException,
Expand All @@ -7,3 +7,14 @@
TimeoutException,
UnsupportedDigestValidationError,
)


__all__ = [
"DigestValidationError",
"InvalidSignatureError",
"PulpException",
"SizeValidationError",
"MissingDigestValidationError",
"TimeoutException",
"UnsupportedDigestValidationError",
]
43 changes: 43 additions & 0 deletions pulpcore/plugin/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,46 @@

from pulpcore.app.models.fields import EncryptedTextField
from pulpcore.app.models.analytics import system_id

__all__ = [
"AlternateContentSource",
"AlternateContentSourcePath",
"AccessPolicy",
"AutoAddObjPermsMixin",
"Artifact",
"AsciiArmoredDetachedSigningService",
"BaseModel",
"Content",
"ContentArtifact",
"ContentManager",
"ContentGuard",
"ContentRedirectContentGuard",
"CreatedResource",
"Distribution",
"Domain",
"Export",
"Exporter",
"Group",
"GroupProgressReport",
"Import",
"Importer",
"FilesystemExporter",
"MasterModel",
"ProgressReport",
"Publication",
"PublishedArtifact",
"PublishedMetadata",
"PulpTemporaryFile",
"Repository",
"Remote",
"RemoteArtifact",
"RepositoryContent",
"RepositoryVersion",
"SigningService",
"Task",
"TaskGroup",
"Upload",
"UploadChunk",
"EncryptedTextField",
"system_id",
]
42 changes: 42 additions & 0 deletions pulpcore/plugin/serializers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,45 @@
NoArtifactContentUploadSerializer,
SingleArtifactContentUploadSerializer,
)


__all__ = [
"AlternateContentSourceSerializer",
"AlternateContentSourcePathSerializer",
"ArtifactSerializer",
"AsyncOperationResponseSerializer",
"ContentChecksumSerializer",
"ContentGuardSerializer",
"ContentRedirectContentGuardSerializer",
"DetailRelatedField",
"DistributionSerializer",
"DomainUniqueValidator",
"ExporterSerializer",
"ExportSerializer",
"GetOrCreateSerializerMixin",
"HiddenFieldsMixin",
"IdentityField",
"ImporterSerializer",
"ImportSerializer",
"ModelSerializer",
"MultipleArtifactContentSerializer",
"NestedRelatedField",
"NoArtifactContentSerializer",
"ProgressReportSerializer",
"PRNField",
"PublicationSerializer",
"RelatedField",
"RemoteSerializer",
"RepositorySerializer",
"RepositorySyncURLSerializer",
"RepositoryVersionRelatedField",
"SingleArtifactContentSerializer",
"SingleContentArtifactField",
"TaskGroupOperationResponseSerializer",
"RepositoryAddRemoveContentSerializer",
"ValidateFieldsMixin",
"validate_unknown_fields",
"TaskSerializer",
"NoArtifactContentUploadSerializer",
"SingleArtifactContentUploadSerializer",
]
5 changes: 4 additions & 1 deletion pulpcore/plugin/storage.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
from pulpcore.app.models.storage import get_tls_path # noqa: F401
from pulpcore.app.models.storage import get_tls_path


__all__ = ["get_tls_path"]
21 changes: 18 additions & 3 deletions pulpcore/plugin/tasking.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Support plugins dispatching tasks
from pulpcore.tasking.tasks import dispatch # noqa: F401
from pulpcore.tasking.tasks import dispatch

from pulpcore.app.tasks import ( # noqa: F401
from pulpcore.app.tasks import (
fs_publication_export,
fs_repo_version_export,
general_create,
Expand All @@ -12,4 +12,19 @@
orphan_cleanup,
reclaim_space,
)
from pulpcore.app.tasks.repository import add_and_remove # noqa: F401
from pulpcore.app.tasks.repository import add_and_remove


__all__ = [
"dispatch",
"fs_publication_export",
"fs_repo_version_export",
"general_create",
"general_create_from_temp_file",
"general_delete",
"general_multi_delete",
"general_update",
"orphan_cleanup",
"reclaim_space",
"add_and_remove",
]
35 changes: 33 additions & 2 deletions pulpcore/plugin/util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pulpcore.app.role_util import ( # noqa: F401
from pulpcore.app.role_util import (
assign_role,
get_groups_with_perms,
get_groups_with_perms_attached_perms,
Expand All @@ -12,7 +12,7 @@
remove_role,
)

from pulpcore.app.util import ( # noqa: F401
from pulpcore.app.util import (
batch_qs,
extract_pk,
get_artifact_url,
Expand All @@ -30,3 +30,34 @@
set_current_user,
resolve_prn,
)


__all__ = [
"assign_role",
"get_groups_with_perms",
"get_groups_with_perms_attached_perms",
"get_groups_with_perms_attached_roles",
"get_objects_for_group",
"get_objects_for_user",
"get_perms_for_model",
"get_users_with_perms",
"get_users_with_perms_attached_perms",
"get_users_with_perms_attached_roles",
"remove_role",
"batch_qs",
"extract_pk",
"get_artifact_url",
"get_prn",
"get_url",
"gpg_verify",
"raise_for_unknown_content_units",
"get_default_domain",
"get_domain",
"get_domain_pk",
"set_domain",
"get_current_user",
"get_current_authenticated_user",
"reverse",
"set_current_user",
"resolve_prn",
]
42 changes: 42 additions & 0 deletions pulpcore/plugin/viewsets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,45 @@
NoArtifactContentUploadViewSet,
SingleArtifactContentUploadViewSet,
)


__all__ = [
"BaseFilterSet",
"OperationPostponedResponse",
"TaskGroupOperationResponse",
"AlternateContentSourceViewSet",
"AsyncUpdateMixin",
"ContentFilter",
"ContentGuardFilter",
"ContentGuardViewSet",
"ContentViewSet",
"DistributionFilter",
"DistributionViewSet",
"ExporterViewSet",
"ExportViewSet",
"ImmutableRepositoryViewSet",
"ImporterViewSet",
"ImportViewSet",
"LabelsMixin",
"NamedModelViewSet",
"NAME_FILTER_OPTIONS",
"NULLABLE_NUMERIC_FILTER_OPTIONS",
"PublicationFilter",
"PublicationViewSet",
"ReadOnlyContentViewSet",
"ReadOnlyRepositoryViewSet",
"RemoteFilter",
"RemoteViewSet",
"RepositoryVersionViewSet",
"RepositoryViewSet",
"RolesMixin",
"TaskGroupViewSet",
"TaskViewSet",
"CharInFilter",
"LabelFilter",
"RepositoryVersionFilter",
"HyperlinkRelatedFilter",
"NoArtifactContentViewSet",
"NoArtifactContentUploadViewSet",
"SingleArtifactContentUploadViewSet",
]

0 comments on commit a5aceb5

Please sign in to comment.