Skip to content

Commit

Permalink
common: drop python-six dependency
Browse files Browse the repository at this point in the history
This means that python-copr-common is no longer compatible with Python 2
and EPEL 7, but we stay compatible with Python 3.6 on EL8+.

If we ever want make it compatible with EL7, we should even there use
the Python 3 (python36) stack.
  • Loading branch information
praiskup committed Sep 20, 2023
1 parent 251d76f commit 06ba7df
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
20 changes: 9 additions & 11 deletions common/copr_common/enums.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import random
import string

from six import with_metaclass

# We don't know how to define the enums without `class`.
# pylint: disable=too-few-public-methods

Expand All @@ -22,7 +20,7 @@ def __getattr__(cls, attr):
return cls._wrap(attr)


class ActionTypeEnum(with_metaclass(EnumType, object)):
class ActionTypeEnum(metaclass=EnumType):
vals = {
"delete": 0,
"rename": 1,
Expand All @@ -39,15 +37,15 @@ class ActionTypeEnum(with_metaclass(EnumType, object)):
}


class ActionResult(with_metaclass(EnumType, object)):
class ActionResult(metaclass=EnumType):
vals = {
'WAITING': 0,
'SUCCESS': 1,
'FAILURE': 2,
}


class DefaultActionPriorityEnum(with_metaclass(EnumType, object)):
class DefaultActionPriorityEnum(metaclass=EnumType):
"""
The higher the 'priority' is, the later the task is taken.
Keep actions priority in range -100 to 100
Expand All @@ -64,7 +62,7 @@ class DefaultActionPriorityEnum(with_metaclass(EnumType, object)):
}


class ActionPriorityEnum(with_metaclass(EnumType, object)):
class ActionPriorityEnum(metaclass=EnumType):
"""
Naming/assigning the values is a little bit tricky because
how the current implementation works (i.e. it is inverted).
Expand All @@ -74,15 +72,15 @@ class ActionPriorityEnum(with_metaclass(EnumType, object)):
vals = {"highest": -99, "lowest": 99}


class BackendResultEnum(with_metaclass(EnumType, object)):
class BackendResultEnum(metaclass=EnumType):
vals = {"waiting": 0, "success": 1, "failure": 2}


class RoleEnum(with_metaclass(EnumType, object)):
class RoleEnum(metaclass=EnumType):
vals = {"user": 0, "admin": 1}


class StatusEnum(with_metaclass(EnumType, object)):
class StatusEnum(metaclass=EnumType):
vals = {
"failed": 0, # build failed
"succeeded": 1, # build succeeded
Expand Down Expand Up @@ -111,7 +109,7 @@ class ModuleStatusEnum(StatusEnum):
"failed", "succeeded", "waiting", "unknown"])


class BuildSourceEnum(with_metaclass(EnumType, object)):
class BuildSourceEnum(metaclass=EnumType):
vals = {"unset": 0,
"link": 1, # url
"upload": 2, # pkg, tmp, url
Expand All @@ -123,7 +121,7 @@ class BuildSourceEnum(with_metaclass(EnumType, object)):
}


class FailTypeEnum(with_metaclass(EnumType, object)):
class FailTypeEnum(metaclass=EnumType):
vals = {"unset": 0,
# General errors mixed with errors for SRPM URL/upload:
"unknown_error": 1,
Expand Down
8 changes: 0 additions & 8 deletions common/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +0,0 @@
import six

if six.PY3:
from unittest import mock
from unittest.mock import MagicMock
else:
import mock
from mock import MagicMock
3 changes: 1 addition & 2 deletions common/tests/test_request.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import logging
from unittest import TestCase
from unittest import TestCase, mock
from requests import RequestException
from copr_common.request import SafeRequest, RequestRetryError
from . import mock


class TestStringMethods(TestCase):
Expand Down

0 comments on commit 06ba7df

Please sign in to comment.