Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ci/ansible/filter/repr.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import absolute_import, division, print_function

from packaging.version import parse as parse_version

__metaclass__ = type
Expand Down
5 changes: 3 additions & 2 deletions .ci/scripts/calc_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@

import argparse
import fileinput
import urllib.request
import sys
import urllib.request

import yaml
from packaging.requirements import Requirement
from packaging.version import Version
import yaml

try:
import tomllib
Expand Down
21 changes: 0 additions & 21 deletions .ci/scripts/check_gettext.sh

This file was deleted.

4 changes: 2 additions & 2 deletions .ci/scripts/check_pulpcore_imports.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
# make sure this script runs at the repo root
cd "$(dirname "$(realpath -e "$0")")"/../..

set -uv
set -u

# check for imports not from pulpcore.plugin. exclude tests
MATCHES=$(grep -n -r --include \*.py "from pulpcore.*import" . | grep -v "tests\|plugin")
MATCHES="$(grep -n -r --include \*.py "from pulpcore.*import" pulp_python | grep -v "tests\|plugin")"

if [ $? -ne 1 ]; then
printf "\nERROR: Detected bad imports from pulpcore:\n"
Expand Down
10 changes: 5 additions & 5 deletions .ci/scripts/check_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
# ///

import argparse
import re
import os
import re
import sys
import tomllib
import typing as t
from pathlib import Path

import yaml
from packaging.version import Version
from git import Repo
from packaging.version import Version

RELEASE_BRANCH_REGEX = r"^([0-9]+)\.([0-9]+)$"
Y_CHANGELOG_EXTS = [".feature"]
Expand Down Expand Up @@ -157,9 +157,9 @@ def main(options: argparse.Namespace, template_config: dict[str, t.Any]) -> int:

if reasons:
curr_version = Version(last_tag)
assert curr_version.base_version.startswith(
branch
), "Current-version has to belong to the current branch!"
assert curr_version.base_version.startswith(branch), (
"Current-version has to belong to the current branch!"
)
next_version = Version(f"{branch}.{curr_version.micro + 1}")
print(
f"A Z-release is needed for {branch}, "
Expand Down
2 changes: 1 addition & 1 deletion .ci/scripts/check_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

import tomllib
import warnings

from packaging.requirements import Requirement

CHECK_MATRIX = [
("pyproject.toml", True, True, True),
("requirements.txt", True, True, True),
("dev_requirements.txt", False, True, False),
("ci_requirements.txt", False, True, True),
("doc_requirements.txt", False, True, False),
("lint_requirements.txt", False, True, True),
Expand Down
1 change: 1 addition & 0 deletions .ci/scripts/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""

import json

from drf_spectacular.validation import JSON_SCHEMA_SPEC_PATH

with open(JSON_SCHEMA_SPEC_PATH) as fh:
Expand Down
7 changes: 4 additions & 3 deletions .ci/scripts/skip_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
*: Error
"""

import sys
import argparse
import os
import re
import git
import sys
import textwrap
import argparse

import git

DOC_PATTERNS = [
r"^docs/",
Expand Down
1 change: 1 addition & 0 deletions .ci/scripts/update_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# For more info visit https://github.com/pulp/plugin_template

import os

from github import Github

g = Github(os.environ.get("GITHUB_TOKEN"))
Expand Down
2 changes: 1 addition & 1 deletion .ci/scripts/validate_commit_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import subprocess
import sys
import tomllib
import yaml
from pathlib import Path

import yaml
from github import Github


Expand Down
34 changes: 0 additions & 34 deletions .flake8

This file was deleted.

15 changes: 4 additions & 11 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,13 @@ jobs:
run: |
yamllint -s -d '{extends: relaxed, rules: {line-length: disable}}' .github/workflows

# run black separately from flake8 to get a diff
- name: "Run black"
- name: "Check formating"
run: |
black --version
black --check --diff .
ruff format --check --diff

# Lint code.
- name: "Run flake8"
- name: "Lint code"
run: |
flake8

- name: "Check for common gettext problems"
run: |
sh .ci/scripts/check_gettext.sh
ruff check

- name: "Run extra lint checks"
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
from git import Repo
from git.exc import GitCommandError

helper = textwrap.dedent("""\
helper = textwrap.dedent(
"""\
Stage the changelog for a release on main branch.

Example:
$ python .github/workflows/scripts/stage-changelog-for-default-branch.py 3.4.0

""")
"""
)

parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter, description=helper)

Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/scripts/update_backport_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
#
# For more info visit https://github.com/pulp/plugin_template

import os
import random

import requests
import yaml
import random
import os


def random_color():
Expand Down
9 changes: 0 additions & 9 deletions dev_requirements.txt

This file was deleted.

4 changes: 1 addition & 3 deletions lint_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
#
# For more info visit https://github.com/pulp/plugin_template

black~=26.3 # Pin style to the year. https://black.readthedocs.io/en/stable/faq.html#how-stable-is-black-s-style
bump-my-version
check-manifest
flake8
flake8-black
packaging
ruff
yamllint
6 changes: 4 additions & 2 deletions pulp_python/app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from gettext import gettext as _

from django.db.models.signals import post_migrate

from pulpcore.plugin import PulpPluginAppConfig
from gettext import gettext as _


class PulpPythonPluginAppConfig(PulpPluginAppConfig):
Expand All @@ -26,7 +28,7 @@ def ready(self):

# TODO: Remove this when https://github.com/pulp/pulpcore/issues/5500 is resolved
def _populate_pypi_access_policies(sender, apps, verbosity, **kwargs):
from pulp_python.app.pypi.views import PyPIView, SimpleView, UploadView, MetadataView
from pulp_python.app.pypi.views import MetadataView, PyPIView, SimpleView, UploadView

try:
AccessPolicy = apps.get_model("core", "AccessPolicy")
Expand Down
5 changes: 3 additions & 2 deletions pulp_python/app/management/commands/repair-python-metadata.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import re
import os
from django.core.management import BaseCommand, CommandError
import re
from gettext import gettext as _

from django.conf import settings
from django.core.management import BaseCommand, CommandError

from pulpcore.plugin.util import extract_pk

from pulp_python.app.models import PythonPackageContent, PythonRepository
from pulp_python.app.utils import artifact_to_python_content_data

Expand Down
1 change: 1 addition & 0 deletions pulp_python/app/modelresource.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pulpcore.plugin.importexport import BaseContentResource
from pulpcore.plugin.modelresources import RepositoryResource
from pulpcore.plugin.util import get_domain

from pulp_python.app.models import (
PythonPackageContent,
PythonRepository,
Expand Down
30 changes: 16 additions & 14 deletions pulp_python/app/models.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
import hashlib
import json
from logging import getLogger
from pathlib import PurePath

from aiohttp.web import json_response
from django.conf import settings
from django.contrib.postgres.fields import ArrayField
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.conf import settings
from django_lifecycle import (
BEFORE_SAVE,
hook,
)
from rest_framework.serializers import ValidationError

from pulpcore.plugin.models import (
AutoAddObjPermsMixin,
BaseModel,
Content,
Publication,
Distribution,
Publication,
Remote,
Repository,
)
from pulpcore.plugin.repo_version_utils import (
collect_duplicates,
remove_duplicates,
validate_repo_version,
)
from pulpcore.plugin.responses import ArtifactResponse
from pulpcore.plugin.util import get_domain, get_domain_pk

from pathlib import PurePath
from .provenance import Provenance
from .utils import (
artifact_to_python_content_data,
PYPI_LAST_SERIAL,
PYPI_SERIAL_CONSTANT,
artifact_to_metadata_artifact,
artifact_to_python_content_data,
canonicalize_name,
python_content_to_json,
PYPI_LAST_SERIAL,
PYPI_SERIAL_CONSTANT,
)
from pulpcore.plugin.repo_version_utils import (
collect_duplicates,
remove_duplicates,
validate_repo_version,
)
from pulpcore.plugin.util import get_domain_pk, get_domain

log = getLogger(__name__)

Expand Down Expand Up @@ -453,8 +454,9 @@ def check_blocklist_for_packages(self, packages):
break
if blocked:
raise ValidationError(
"Blocklisted packages cannot be added to this repository: "
"{}".format(", ".join(blocked))
"Blocklisted packages cannot be added to this repository: {}".format(
", ".join(blocked)
)
)


Expand Down
Loading
Loading