Support tox4, update style to match Black 23.1a1

This aligns code with https://github.com/psf/black/pull/3302

Depends-On: https://review.opendev.org/866943
Change-Id: Icfbca2fab8adeb677b980d01f797f194f580838e
This commit is contained in:
Dale Smith 2023-01-04 16:12:45 +13:00
parent a84d0da632
commit 6b1856b4eb
27 changed files with 1 additions and 44 deletions

View File

@ -6,7 +6,6 @@ import jsonfield.fields
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
("api", "0001_initial"), ("api", "0001_initial"),
] ]

View File

@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
("actions", "0001_initial"), ("actions", "0001_initial"),
] ]

View File

@ -5,7 +5,6 @@ from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
("actions", "0002_action_auto_approve"), ("actions", "0002_action_auto_approve"),
] ]

View File

@ -6,7 +6,6 @@ import django.db.models.deletion
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
("tasks", "0001_initial"), ("tasks", "0001_initial"),
("actions", "0003_auto_20190610_0205"), ("actions", "0003_auto_20190610_0205"),

View File

@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
("actions", "0004_auto_20190610_0209"), ("actions", "0004_auto_20190610_0209"),
] ]

View File

@ -100,7 +100,6 @@ def _build_default_email_group(group_name):
class SendAdditionalEmailAction(BaseAction): class SendAdditionalEmailAction(BaseAction):
serializer = serializers.SendAdditionalEmailSerializer serializer = serializers.SendAdditionalEmailSerializer
config_group = groups.DynamicNameConfigGroup( config_group = groups.DynamicNameConfigGroup(

View File

@ -294,7 +294,6 @@ class UpdateProjectQuotasAction(BaseAction, QuotaMixin):
) )
def _get_email(self): def _get_email(self):
if CONF.identity.username_is_email: if CONF.identity.username_is_email:
return self.action.task.keystone_user["username"] return self.action.task.keystone_user["username"]
else: else:

View File

@ -322,7 +322,6 @@ class EditUserRolesAction(UserIdAction, ProjectMixin, UserMixin):
return True return True
def _validate_role_permissions(self): def _validate_role_permissions(self):
id_manager = user_store.IdentityManager() id_manager = user_store.IdentityManager()
current_user_roles = id_manager.get_roles( current_user_roles = id_manager.get_roles(

View File

@ -7,7 +7,6 @@ import adjutant.api.models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [] dependencies = []
operations = [ operations = [

View File

@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
("api", "0001_initial"), ("api", "0001_initial"),
] ]

View File

@ -5,7 +5,6 @@ import jsonfield.fields
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
("api", "0002_auto_20160815_2249"), ("api", "0002_auto_20160815_2249"),
] ]

View File

@ -4,7 +4,6 @@ from django.db import migrations, models
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
("api", "0003_task_approved_by"), ("api", "0003_task_approved_by"),
] ]

View File

@ -5,7 +5,6 @@ from django.db import migrations
class Migration(migrations.Migration): class Migration(migrations.Migration):
atomic = False atomic = False
dependencies = [ dependencies = [

View File

@ -6,7 +6,6 @@ import django.db.models.deletion
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
("tasks", "0001_initial"), ("tasks", "0001_initial"),
("actions", "0003_auto_20190610_0205"), ("actions", "0003_auto_20190610_0205"),

View File

@ -6,7 +6,6 @@ import django.db.models.deletion
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
("tasks", "0001_initial"), ("tasks", "0001_initial"),
("actions", "0003_auto_20190610_0205"), ("actions", "0003_auto_20190610_0205"),

View File

@ -5,7 +5,6 @@ from django.db import migrations
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
("api", "0005_auto_20190610_0209"), ("api", "0005_auto_20190610_0209"),
("tasks", "0001_initial"), ("tasks", "0001_initial"),

View File

@ -29,7 +29,6 @@ from adjutant.config import CONF
class UserList(tasks.InviteUser): class UserList(tasks.InviteUser):
url = r"^openstack/users/?$" url = r"^openstack/users/?$"
config_group = groups.DynamicNameConfigGroup( config_group = groups.DynamicNameConfigGroup(
@ -176,7 +175,6 @@ class UserList(tasks.InviteUser):
class UserDetail(BaseDelegateAPI): class UserDetail(BaseDelegateAPI):
url = r"^openstack/users/(?P<user_id>\w+)/?$" url = r"^openstack/users/(?P<user_id>\w+)/?$"
config_group = groups.DynamicNameConfigGroup( config_group = groups.DynamicNameConfigGroup(
@ -263,7 +261,6 @@ class UserDetail(BaseDelegateAPI):
class UserRoles(BaseDelegateAPI): class UserRoles(BaseDelegateAPI):
url = r"^openstack/users/(?P<user_id>\w+)/roles/?$" url = r"^openstack/users/(?P<user_id>\w+)/roles/?$"
config_group = groups.DynamicNameConfigGroup( config_group = groups.DynamicNameConfigGroup(
@ -338,7 +335,6 @@ class UserRoles(BaseDelegateAPI):
class RoleList(BaseDelegateAPI): class RoleList(BaseDelegateAPI):
url = r"^openstack/roles/?$" url = r"^openstack/roles/?$"
@utils.mod_or_admin @utils.mod_or_admin
@ -490,7 +486,6 @@ class UpdateProjectQuotas(BaseDelegateAPI):
@utils.mod_or_admin @utils.mod_or_admin
def post(self, request): def post(self, request):
request.data["project_id"] = request.keystone_user["project_id"] request.data["project_id"] = request.keystone_user["project_id"]
self.project_id = request.keystone_user["project_id"] self.project_id = request.keystone_user["project_id"]

View File

@ -29,7 +29,6 @@ from adjutant.api.v1.base import BaseDelegateAPI
class CreateProjectAndUser(BaseDelegateAPI): class CreateProjectAndUser(BaseDelegateAPI):
url = r"^actions/CreateProjectAndUser/?$" url = r"^actions/CreateProjectAndUser/?$"
config_group = groups.DynamicNameConfigGroup( config_group = groups.DynamicNameConfigGroup(
@ -84,7 +83,6 @@ class CreateProjectAndUser(BaseDelegateAPI):
class InviteUser(BaseDelegateAPI): class InviteUser(BaseDelegateAPI):
url = r"^actions/InviteUser/?$" url = r"^actions/InviteUser/?$"
task_type = "invite_user_to_project" task_type = "invite_user_to_project"
@ -118,7 +116,6 @@ class InviteUser(BaseDelegateAPI):
class ResetPassword(BaseDelegateAPI): class ResetPassword(BaseDelegateAPI):
url = r"^actions/ResetPassword/?$" url = r"^actions/ResetPassword/?$"
task_type = "reset_user_password" task_type = "reset_user_password"
@ -164,7 +161,6 @@ class ResetPassword(BaseDelegateAPI):
class EditUser(BaseDelegateAPI): class EditUser(BaseDelegateAPI):
url = r"^actions/EditUser/?$" url = r"^actions/EditUser/?$"
task_type = "edit_user_roles" task_type = "edit_user_roles"
@ -186,7 +182,6 @@ class EditUser(BaseDelegateAPI):
class UpdateEmail(BaseDelegateAPI): class UpdateEmail(BaseDelegateAPI):
url = r"^actions/UpdateEmail/?$" url = r"^actions/UpdateEmail/?$"
task_type = "update_user_email" task_type = "update_user_email"

View File

@ -860,7 +860,6 @@ class DelegateAPITests(AdjutantAPITestCase):
self.assertEqual(len(mail.outbox), 3) self.assertEqual(len(mail.outbox), 3)
def test_update_email_task_invalid_email(self): def test_update_email_task_invalid_email(self):
user = fake_clients.FakeUser( user = fake_clients.FakeUser(
name="test@example.com", password="123", email="test@example.com" name="test@example.com", password="123", email="test@example.com"
) )
@ -897,7 +896,6 @@ class DelegateAPITests(AdjutantAPITestCase):
}, },
) )
def test_update_email_pre_existing_user_with_email(self): def test_update_email_pre_existing_user_with_email(self):
user = fake_clients.FakeUser( user = fake_clients.FakeUser(
name="test@example.com", password="123", email="test@example.com" name="test@example.com", password="123", email="test@example.com"
) )
@ -940,7 +938,6 @@ class DelegateAPITests(AdjutantAPITestCase):
}, },
) )
def test_update_email_user_with_email_username_not_email(self): def test_update_email_user_with_email_username_not_email(self):
user = fake_clients.FakeUser( user = fake_clients.FakeUser(
name="test", password="123", email="test@example.com" name="test", password="123", email="test@example.com"
) )
@ -1006,7 +1003,6 @@ class DelegateAPITests(AdjutantAPITestCase):
}, },
) )
def test_update_email_task_username_not_email(self): def test_update_email_task_username_not_email(self):
user = fake_clients.FakeUser( user = fake_clients.FakeUser(
name="test_user", password="123", email="test@example.com" name="test_user", password="123", email="test@example.com"
) )

View File

@ -48,7 +48,6 @@ class SingleVersionView(APIView):
""" """
def get(self, request): def get(self, request):
version = _VERSIONS.get(self.version, {}).copy() version = _VERSIONS.get(self.version, {}).copy()
if not version: if not version:
return Response({"error": "Not Found"}, status=404) return Response({"error": "Not Found"}, status=404)

View File

@ -42,7 +42,6 @@ def get_auth_session():
"""Returns a global auth session to be shared by all clients""" """Returns a global auth session to be shared by all clients"""
global client_auth_session global client_auth_session
if not client_auth_session: if not client_auth_session:
auth = v3.Password( auth = v3.Password(
username=CONF.identity.auth.username, username=CONF.identity.auth.username,
password=CONF.identity.auth.password, password=CONF.identity.auth.password,

View File

@ -217,7 +217,6 @@ class FakeManager(object):
for assignment in identity_cache["role_assignments"]: for assignment in identity_cache["role_assignments"]:
if assignment.scope["project"]["id"] == project.id: if assignment.scope["project"]["id"] == project.id:
user = users.get(assignment.user["id"]) user = users.get(assignment.user["id"])
if not user: if not user:
user = self.get_user(assignment.user["id"]) user = self.get_user(assignment.user["id"])
@ -315,7 +314,6 @@ class FakeManager(object):
assignment.user["id"] == user.id assignment.user["id"] == user.id
and assignment.scope["project"]["id"] == project.id and assignment.scope["project"]["id"] == project.id
): ):
if ( if (
assignment.scope.get("OS-INHERIT:inherited_to") and not inherited assignment.scope.get("OS-INHERIT:inherited_to") and not inherited
) or ( ) or (
@ -735,13 +733,11 @@ class FakeOctaviaClient(object):
class FakeTroveClient(object): class FakeTroveClient(object):
class FakeTroveQuotaManager(object): class FakeTroveQuotaManager(object):
FakeTroveResource = namedtuple( FakeTroveResource = namedtuple(
"FakeTroveResource", ["resource", "in_use", "reserved", "limit"] "FakeTroveResource", ["resource", "in_use", "reserved", "limit"]
) )
def __init__(self, region): def __init__(self, region):
global trove_cache global trove_cache
self.region = region self.region = region
if region not in trove_cache: if region not in trove_cache:

View File

@ -143,7 +143,6 @@ class IdentityManager(object): # pragma: no cover
def create_user( def create_user(
self, name, password, email, created_on, domain=None, default_project=None self, name, password, email, created_on, domain=None, default_project=None
): ):
user = self.ks_client.users.create( user = self.ks_client.users.create(
name=name, name=name,
password=password, password=password,

View File

@ -8,7 +8,6 @@ import jsonfield.fields
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
("api", "0005_auto_20190610_0209"), ("api", "0005_auto_20190610_0209"),
] ]

View File

@ -6,7 +6,6 @@ import jsonfield.fields
class Migration(migrations.Migration): class Migration(migrations.Migration):
dependencies = [ dependencies = [
("tasks", "0001_initial"), ("tasks", "0001_initial"),
] ]

View File

@ -28,7 +28,6 @@ from adjutant import exceptions
def make_task_config(task_class): def make_task_config(task_class):
config_group = groups.DynamicNameConfigGroup() config_group = groups.DynamicNameConfigGroup()
config_group.register_child_config( config_group.register_child_config(
fields.BoolConfig( fields.BoolConfig(
@ -245,7 +244,6 @@ class BaseTask(object):
return hashlib.sha256(str(hashable_list).encode("utf-8")).hexdigest() return hashlib.sha256(str(hashable_list).encode("utf-8")).hexdigest()
def _handle_duplicates(self, hash_key): def _handle_duplicates(self, hash_key):
duplicate_tasks = Task.objects.filter( duplicate_tasks = Task.objects.filter(
hash_key=hash_key, completed=0, cancelled=0 hash_key=hash_key, completed=0, cancelled=0
) )
@ -468,7 +466,6 @@ class BaseTask(object):
token.delete() token.delete()
def submit(self, token_data=None, keystone_user=None): def submit(self, token_data=None, keystone_user=None):
self.confirm_state(approved=True, completed=False, cancelled=False) self.confirm_state(approved=True, completed=False, cancelled=False)
required_fields = set() required_fields = set()

View File

@ -1,6 +1,5 @@
[tox] [tox]
envlist = py3,pep8,black_check,cover_report envlist = py3,pep8,black_check,cover_report
skipsdist = True
minversion = 3.1.1 minversion = 3.1.1
ignore_basepython_conflict = True ignore_basepython_conflict = True
@ -15,7 +14,7 @@ commands =
find adjutant -type f -name "*.pyc" -delete find adjutant -type f -name "*.pyc" -delete
adjutant-api test {posargs} adjutant-api test {posargs}
setenv = VIRTUAL_ENV={envdir} setenv = VIRTUAL_ENV={envdir}
whitelist_externals = allowlist_externals =
find find
[testenv:pep8] [testenv:pep8]