From 8451a927e3de90b176ee07768551aa9072d50c9f Mon Sep 17 00:00:00 2001 From: Alexander Saprykin Date: Fri, 25 Oct 2024 16:42:56 +0200 Subject: [PATCH] Enable flake8-pyi plugin for ruff (#2340) --- galaxy_ng/app/api/utils.py | 9 +++++++-- galaxy_ng/tests/integration/dab/test_dab_rbac.py | 12 ++++++++---- pyproject.toml | 2 ++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/galaxy_ng/app/api/utils.py b/galaxy_ng/app/api/utils.py index 7f244a723e..cc32c78af3 100644 --- a/galaxy_ng/app/api/utils.py +++ b/galaxy_ng/app/api/utils.py @@ -1,6 +1,7 @@ import os import re import socket +from typing import NamedTuple from django.utils.translation import gettext_lazy as _ from django.http import Http404 @@ -9,7 +10,6 @@ from rest_framework import serializers from pulpcore.plugin import models as pulp_models -from collections import namedtuple from requests.adapters import HTTPAdapter from urllib3.connection import HTTPConnection from urllib3.connectionpool import HTTPConnectionPool @@ -17,7 +17,12 @@ from galaxy_importer.schema import MAX_LENGTH_NAME, MAX_LENGTH_VERSION from galaxy_ng.app.constants import AAP_VERSION_FILE_PATH -CollectionFilename = namedtuple("CollectionFilename", ["namespace", "name", "version"]) + +class CollectionFilename(NamedTuple): + namespace: str + name: str + version: str + LOCALHOST = "localhost" FILENAME_REGEXP = re.compile( diff --git a/galaxy_ng/tests/integration/dab/test_dab_rbac.py b/galaxy_ng/tests/integration/dab/test_dab_rbac.py index 8abb9b9a74..d985a4bf48 100644 --- a/galaxy_ng/tests/integration/dab/test_dab_rbac.py +++ b/galaxy_ng/tests/integration/dab/test_dab_rbac.py @@ -1,7 +1,7 @@ import contextlib import json import os -from collections import namedtuple +from typing import NamedTuple import pytest @@ -16,6 +16,13 @@ pytestmark = pytest.mark.qa # noqa: F821 +class Artifact(NamedTuple): + name: str + namespace: str + published: bool + version: str + + @pytest.mark.skip(reason="we are not aiming for 1:1 anymore") @pytest.mark.deployment_standalone def test_dab_roledefs_match_pulp_roles(galaxy_client): @@ -248,9 +255,6 @@ def test_dab_rbac_namespace_owner_by_user_or_team( }) ) - # we need an artifact-like object for the set_certification function .. - Artifact = namedtuple('Artifact', ['name', 'namespace', 'published', 'version']) - # try to upload a collection as the user... import_result = upload_test_collection( ugc, diff --git a/pyproject.toml b/pyproject.toml index 6c13401d34..e26faa7c53 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -125,6 +125,8 @@ select = [ "PIE", # flake8-pytest-style "PT", + # flake8-pyi + "PYI", # ruff specific rules "RUF", # flake8-simplify