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_rust | 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
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
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
3 changes: 0 additions & 3 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
16 changes: 8 additions & 8 deletions pulp_rust/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
from logging import getLogger

from django.db import models
from django_lifecycle import hook, AFTER_CREATE

from pulp_rust.app.utils import (
canonicalize_crate_name,
extract_cargo_toml,
extract_dependencies,
)
from django_lifecycle import AFTER_CREATE, hook

from pulpcore.plugin.models import (
Content,
Distribution,
Remote,
Repository,
Distribution,
)
from pulpcore.plugin.util import get_domain_pk

from pulp_rust.app.utils import (
canonicalize_crate_name,
extract_cargo_toml,
extract_dependencies,
)

logger = getLogger(__name__)

# Cache for the "dl" template from each registry's config.json.
Expand Down
2 changes: 1 addition & 1 deletion pulp_rust/app/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

from gettext import gettext as _

from rest_framework import serializers

from pulpcore.plugin import models as core_models
Expand Down
2 changes: 1 addition & 1 deletion pulp_rust/app/tasks/synchronizing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from gettext import gettext as _
import logging
from gettext import gettext as _

from pulpcore.plugin.models import Artifact, ProgressReport, Remote, Repository # noqa
from pulpcore.plugin.stages import (
Expand Down
4 changes: 2 additions & 2 deletions pulp_rust/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
from django.urls import path

from pulp_rust.app.views import (
IndexRoot,
CargoIndexApiViewSet,
CargoDownloadApiView,
CargoIndexApiViewSet,
CargoMeApiView,
CargoPublishApiView,
IndexRoot,
)

if settings.DOMAIN_ENABLED:
Expand Down
2 changes: 1 addition & 1 deletion pulp_rust/app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def validate_crate_version(version):
if not version:
return "crate version must not be empty"
if not SEMVER_RE.match(version):
return f"invalid semver: `{version}` " "(expected MAJOR.MINOR.PATCH[-prerelease][+build])"
return f"invalid semver: `{version}` (expected MAJOR.MINOR.PATCH[-prerelease][+build])"
return None


Expand Down
45 changes: 22 additions & 23 deletions pulp_rust/app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,49 @@
import os
import struct
import tempfile
import urllib.request
import urllib.error
import urllib.request
from urllib.parse import urljoin

from rest_framework.renderers import BaseRenderer, JSONRenderer
from rest_framework.views import APIView
from rest_framework.viewsets import ViewSet
from rest_framework.exceptions import Throttled
from django.core.exceptions import ObjectDoesNotExist
from django.shortcuts import redirect, get_object_or_404

from django.http.response import (
Http404,
HttpResponseNotFound,
HttpResponse,
HttpResponseNotFound,
)
from django.shortcuts import get_object_or_404, redirect
from drf_spectacular.utils import extend_schema
from dynaconf import settings
from urllib.parse import urljoin
from rest_framework.exceptions import Throttled
from rest_framework.renderers import BaseRenderer, JSONRenderer
from rest_framework.views import APIView
from rest_framework.viewsets import ViewSet

from pulpcore.plugin.util import get_domain
from pulpcore.plugin.tasking import dispatch
from pulpcore.plugin.util import get_domain

from pulp_rust.app.auth import require_cargo_token
from pulp_rust.app.models import (
RustDistribution,
RustContent,
RustDistribution,
RustPackageYank,
_strip_sparse_prefix,
)
from pulp_rust.app.auth import require_cargo_token
from pulp_rust.app.utils import (
validate_crate_name,
validate_crate_version,
canonicalize_crate_name,
strip_semver_build_metadata,
from pulp_rust.app.serializers import (
IndexRootSerializer,
RustContentSerializer,
)
from pulp_rust.app.tasks import (
ayank_package,
aunyank_package,
apublish_package,
aunyank_package,
ayank_package,
parse_cargo_publish_body,
)
from pulp_rust.app.serializers import (
IndexRootSerializer,
RustContentSerializer,
from pulp_rust.app.utils import (
canonicalize_crate_name,
strip_semver_build_metadata,
validate_crate_name,
validate_crate_version,
)

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -195,7 +194,7 @@ def retrieve(self, request, path, **kwargs):
)
except (urllib.error.URLError, TimeoutError) as e:
log.warning(
"Upstream index request failed for %s: %s, " "falling back to cached content",
"Upstream index request failed for %s: %s, falling back to cached content",
upstream_url,
e,
)
Expand Down
Loading