From 2c3ca0bda69b2debbeccefbe27e6dbd7cc22b3c3 Mon Sep 17 00:00:00 2001 From: Alexander Saprykin Date: Wed, 23 Oct 2024 19:01:06 +0200 Subject: [PATCH] Enable flake8-pyi plugin for ruff --- galaxy_ng/app/api/utils.py | 8 ++++++-- galaxy_ng/tests/integration/dab/test_dab_rbac.py | 10 ++++++---- pyproject.toml | 2 ++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/galaxy_ng/app/api/utils.py b/galaxy_ng/app/api/utils.py index 7f244a723e..421f5b4024 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,11 @@ 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..6a8b52fcd6 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 @@ -15,6 +15,11 @@ 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 @@ -248,9 +253,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 b456eb9eab..b36cc49996 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -121,6 +121,8 @@ select = [ "UP", # flake8-pytest-style "PT", + # flake8-pyi + "PYI", # ruff specific rules "RUF", # flake8-simplify