diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0789a0e945..307cf4e17f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,12 +27,11 @@ repos: # hooks: # - id: pyupgrade # args: ['--py38-plus'] - # TODO(gtema): Uncomment it once all files are blackified - # - repo: https://github.com/psf/black - # rev: 24.4.0 - # hooks: - # - id: black - # args: ['-S', '-l', '79'] + - repo: https://github.com/psf/black + rev: 24.4.0 + hooks: + - id: black + args: ['-S', '-l', '79'] # - repo: https://opendev.org/openstack/hacking # rev: 6.1.0 # hooks: diff --git a/devstack/tools/oidc/setup_keycloak_client.py b/devstack/tools/oidc/setup_keycloak_client.py index 15fa37b41f..cc296a624d 100644 --- a/devstack/tools/oidc/setup_keycloak_client.py +++ b/devstack/tools/oidc/setup_keycloak_client.py @@ -6,6 +6,7 @@ KEYCLOAK_PASSWORD = os.environ.get('KEYCLOAK_PASSWORD') KEYCLOAK_URL = os.environ.get('KEYCLOAK_URL') HOST_IP = os.environ.get('HOST_IP', 'localhost') + class KeycloakClient(object): def __init__(self): self.session = requests.session() @@ -29,7 +30,7 @@ class KeycloakClient(object): r = requests.post(self.token_endpoint(realm), data=params).json() headers = { 'Authorization': ("Bearer %s" % r['access_token']), - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', } self.session.headers.update(headers) return r @@ -43,7 +44,9 @@ class KeycloakClient(object): 'implicitFlowEnabled': True, 'directAccessGrantsEnabled': True, } - return self.session.post(self.construct_url(realm, 'clients'), json=data) + return self.session.post( + self.construct_url(realm, 'clients'), json=data + ) def main(): @@ -51,7 +54,7 @@ def main(): redirect_uris = [ f'http://{HOST_IP}/identity/v3/auth/OS-FEDERATION/identity_providers/sso/protocols/openid/websso', - f'http://{HOST_IP}/identity/v3/auth/OS-FEDERATION/websso/openid' + f'http://{HOST_IP}/identity/v3/auth/OS-FEDERATION/websso/openid', ] c.create_client('master', 'devstack', 'nomoresecret', redirect_uris) diff --git a/doc/source/conf.py b/doc/source/conf.py index 149b7cd961..213e7621b7 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -44,7 +44,7 @@ extensions = [ 'sphinxcontrib.apidoc', 'sphinxcontrib.seqdiag', 'sphinx_feature_classification.support_matrix', - 'sphinxcontrib.blockdiag' + 'sphinxcontrib.blockdiag', ] blockdiag_html_image_format = 'SVG' @@ -134,8 +134,13 @@ modindex_common_prefix = ['keystone.'] # List of tuples 'sourcefile', 'target', u'title', u'Authors name', 'manual' man_pages = [ - ('cli/keystone-manage', 'keystone-manage', 'Keystone Management Utility', - ['OpenStack'], 1) + ( + 'cli/keystone-manage', + 'keystone-manage', + 'Keystone Management Utility', + ['OpenStack'], + 1, + ) ] @@ -235,8 +240,14 @@ latex_elements = { # NOTE(gyee): Specify toctree_only=True for a better document structure of # the generated PDF file. latex_documents = [ - ('index', 'doc-keystone.tex', 'Keystone Documentation', - 'OpenStack', 'manual', True) + ( + 'index', + 'doc-keystone.tex', + 'Keystone Documentation', + 'OpenStack', + 'manual', + True, + ) ] # The name of an image file (relative to this directory) to place at the top of @@ -266,9 +277,15 @@ latex_documents = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'keystone', 'Keystone Documentation', - 'OpenStack', 'keystone', 'One line description of project.', - 'Miscellaneous'), + ( + 'index', + 'keystone', + 'Keystone Documentation', + 'OpenStack', + 'keystone', + 'One line description of project.', + 'Miscellaneous', + ), ] # Documents to append as an appendix to all manuals. diff --git a/keystone/api/users.py b/keystone/api/users.py index ff12bd9344..3a4c157e20 100644 --- a/keystone/api/users.py +++ b/keystone/api/users.py @@ -644,9 +644,11 @@ class UserAppCredListCreateResource(ks_flask.ResourceBase): # explicitly if not already there for role in roles: for implied_role in PROVIDERS.role_api.list_implied_roles( - role['id']): + role['id'] + ): imp_role_obj = PROVIDERS.role_api.get_role( - implied_role['implied_role_id']) + implied_role['implied_role_id'] + ) if imp_role_obj['id'] not in [x['id'] for x in roles]: roles.append(imp_role_obj) # NOTE(cmurphy): The user is not allowed to add a role that is not diff --git a/keystone/tests/unit/test_v3_application_credential.py b/keystone/tests/unit/test_v3_application_credential.py index 750475022c..a57e68f2e6 100644 --- a/keystone/tests/unit/test_v3_application_credential.py +++ b/keystone/tests/unit/test_v3_application_credential.py @@ -92,7 +92,8 @@ class ApplicationCredentialTestCase(test_v3.RestfulTestCase): '/v3/users/%s/application_credentials' % self.user_id, json=app_cred_body, expected_status_code=http.client.CREATED, - headers={'X-Auth-Token': token}) + headers={'X-Auth-Token': token}, + ) # Create operation returns the secret self.assertIn('secret', resp.json['application_credential']) # But not the stored hash @@ -100,7 +101,7 @@ class ApplicationCredentialTestCase(test_v3.RestfulTestCase): # Ensure implied role is also granted self.assertIn( implied_role_id, - [x['id'] for x in resp.json["application_credential"]["roles"]] + [x['id'] for x in resp.json["application_credential"]["roles"]], ) def test_create_application_credential_with_secret(self): diff --git a/releasenotes/source/conf.py b/releasenotes/source/conf.py index c167981076..883bc2ffae 100644 --- a/releasenotes/source/conf.py +++ b/releasenotes/source/conf.py @@ -196,9 +196,13 @@ htmlhelp_basename = 'KeystoneReleaseNotesdoc' # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - ('index', 'KeystoneReleaseNotes.tex', - 'Keystone Release Notes Documentation', - 'Keystone Developers', 'manual'), + ( + 'index', + 'KeystoneReleaseNotes.tex', + 'Keystone Release Notes Documentation', + 'Keystone Developers', + 'manual', + ), ] # The name of an image file (relative to this directory) to place at the top of @@ -227,8 +231,13 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'keystonereleasenotes', 'Keystone Release Notes Documentation', - ['Keystone Developers'], 1) + ( + 'index', + 'keystonereleasenotes', + 'Keystone Release Notes Documentation', + ['Keystone Developers'], + 1, + ) ] # If true, show URL addresses after external links. @@ -241,10 +250,15 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'KeystoneReleaseNotes', 'Keystone Release Notes Documentation', - 'Keystone Developers', 'KeystoneReleaseNotes', - 'Identity, Authentication and Access Management for OpenStack.', - 'Miscellaneous'), + ( + 'index', + 'KeystoneReleaseNotes', + 'Keystone Release Notes Documentation', + 'Keystone Developers', + 'KeystoneReleaseNotes', + 'Identity, Authentication and Access Management for OpenStack.', + 'Miscellaneous', + ), ] # Documents to append as an appendix to all manuals. diff --git a/setup.py b/setup.py index cd35c3c35b..481505b030 100644 --- a/setup.py +++ b/setup.py @@ -15,6 +15,4 @@ import setuptools -setuptools.setup( - setup_requires=['pbr>=2.0.0'], - pbr=True) +setuptools.setup(setup_requires=['pbr>=2.0.0'], pbr=True) diff --git a/tox.ini b/tox.ini index 5c6c4f4283..b67c0c4931 100644 --- a/tox.ini +++ b/tox.ini @@ -23,8 +23,9 @@ passenv = http_proxy,HTTP_PROXY,https_proxy,HTTPS_PROXY,no_proxy,NO_PROXY,PBR_VE [testenv:pep8] deps = {[testenv]deps} + pre-commit commands = - flake8 + pre-commit run --all-files --show-diff-on-failure # Run bash8 during pep8 runs to ensure violations are caught by # the check and gate queues bashate devstack/plugin.sh