Skip to content

Commit a092422

Browse files
committed
UA-4672 | Format with ruff before merge.
1 parent 15c8705 commit a092422

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+2086
-1865
lines changed

docs/conf.py

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
extensions = []
3232

3333
# Add any paths that contain templates here, relative to this directory.
34-
templates_path = ['_templates']
34+
templates_path = ["_templates"]
3535

3636
# The suffix(es) of source filenames.
3737
# You can specify multiple suffix as a list of string:
@@ -41,28 +41,28 @@
4141
# source_encoding = 'utf-8-sig'
4242

4343
# The master toctree document.
44-
master_doc = 'index'
44+
master_doc = "index"
4545

4646
# General information about the project.
47-
project = u'django-oidc-provider'
48-
copyright = u'2025, Juan Ignacio Fiorentino'
49-
author = u'Juan Ignacio Fiorentino'
47+
project = "django-oidc-provider"
48+
copyright = "2025, Juan Ignacio Fiorentino"
49+
author = "Juan Ignacio Fiorentino"
5050

5151
# The version info for the project you're documenting, acts as replacement for
5252
# |version| and |release|, also used in various other places throughout the
5353
# built documents.
5454
#
5555
# The short X.Y version.
56-
version = u'0.8'
56+
version = "0.8"
5757
# The full version, including alpha/beta/rc tags.
58-
release = u'0.8'
58+
release = "0.8"
5959

6060
# The language for content autogenerated by Sphinx. Refer to documentation
6161
# for a list of supported languages.
6262
#
6363
# This is also used if you do content translation via gettext catalogs.
6464
# Usually you set "language" from the command line for these cases.
65-
language = 'en'
65+
language = "en"
6666

6767
# There are two options for replacing |today|: either, you set today to some
6868
# non-false value, then it is used:
@@ -72,7 +72,7 @@
7272

7373
# List of patterns, relative to source directory, that match files and
7474
# directories to ignore when looking for source files.
75-
exclude_patterns = ['_build']
75+
exclude_patterns = ["_build"]
7676

7777
# The reST default role (used for this markup: `text`) to use for all
7878
# documents.
@@ -90,7 +90,7 @@
9090
# show_authors = False
9191

9292
# The name of the Pygments (syntax highlighting) style to use.
93-
pygments_style = 'sphinx'
93+
pygments_style = "sphinx"
9494

9595
# A list of ignored prefixes for module index sorting.
9696
# modindex_common_prefix = []
@@ -106,7 +106,7 @@
106106

107107
# The theme to use for HTML and HTML Help pages. See the documentation for
108108
# a list of builtin themes.
109-
html_theme = 'sphinx_rtd_theme'
109+
html_theme = "sphinx_rtd_theme"
110110

111111
# Theme options are theme-specific and customize the look and feel of a theme
112112
# further. For a list of options available for each theme, see the
@@ -135,7 +135,7 @@
135135
# Add any paths that contain custom static files (such as style sheets) here,
136136
# relative to this directory. They are copied after the builtin static files,
137137
# so a file named "default.css" will overwrite the builtin "default.css".
138-
html_static_path = ['_static']
138+
html_static_path = ["_static"]
139139

140140
# Add any extra paths that contain custom files (such as robots.txt or
141141
# .htaccess) here, relative to this directory. These files are copied
@@ -198,20 +198,17 @@
198198
# html_search_scorer = 'scorer.js'
199199

200200
# Output file base name for HTML help builder.
201-
htmlhelp_basename = 'django-oidc-providerdoc'
201+
htmlhelp_basename = "django-oidc-providerdoc"
202202

203203
# -- Options for LaTeX output ---------------------------------------------
204204

205205
latex_elements = {
206206
# The paper size ('letterpaper' or 'a4paper').
207207
# 'papersize': 'letterpaper',
208-
209208
# The font size ('10pt', '11pt' or '12pt').
210209
# 'pointsize': '10pt',
211-
212210
# Additional stuff for the LaTeX preamble.
213211
# 'preamble': '',
214-
215212
# Latex figure (float) alignment
216213
# 'figure_align': 'htbp',
217214
}
@@ -220,8 +217,13 @@
220217
# (source start file, target name, title,
221218
# author, documentclass [howto, manual, or own class]).
222219
latex_documents = [
223-
(master_doc, 'django-oidc-provider.tex', u'django-oidc-provider Documentation',
224-
u'Juan Ignacio Fiorentino', 'manual'),
220+
(
221+
master_doc,
222+
"django-oidc-provider.tex",
223+
"django-oidc-provider Documentation",
224+
"Juan Ignacio Fiorentino",
225+
"manual",
226+
),
225227
]
226228

227229
# The name of an image file (relative to this directory) to place at the top of
@@ -250,8 +252,7 @@
250252
# One entry per manual page. List of tuples
251253
# (source start file, name, description, authors, manual section).
252254
man_pages = [
253-
(master_doc, 'django-oidc-provider', u'django-oidc-provider Documentation',
254-
[author], 1)
255+
(master_doc, "django-oidc-provider", "django-oidc-provider Documentation", [author], 1)
255256
]
256257

257258
# If true, show URL addresses after external links.
@@ -264,9 +265,15 @@
264265
# (source start file, target name, title, author,
265266
# dir menu entry, description, category)
266267
texinfo_documents = [
267-
(master_doc, 'django-oidc-provider', u'django-oidc-provider Documentation',
268-
author, 'django-oidc-provider', 'One line description of project.',
269-
'Miscellaneous'),
268+
(
269+
master_doc,
270+
"django-oidc-provider",
271+
"django-oidc-provider Documentation",
272+
author,
273+
"django-oidc-provider",
274+
"One line description of project.",
275+
"Miscellaneous",
276+
),
270277
]
271278

272279
# Documents to append as an appendix to all manuals.
@@ -328,7 +335,7 @@
328335
# epub_post_files = []
329336

330337
# A list of files that should not be packed into the epub file.
331-
epub_exclude_files = ['search.html']
338+
epub_exclude_files = ["search.html"]
332339

333340
# The depth of the table of contents in toc.ncx.
334341
# epub_tocdepth = 3

example/app/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
55

6-
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
6+
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
77

88
SECRET_KEY = "c14d549c574e4d8cf162404ef0b04598"
99

example/app/urls.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
from django.contrib.auth import views as auth_views
2-
from django.urls import include, re_path
31
from django.contrib import admin
2+
from django.contrib.auth import views as auth_views
3+
from django.urls import include
4+
from django.urls import re_path
45
from django.views.generic import TemplateView
56

6-
77
urlpatterns = [
8-
re_path(r"^$", TemplateView.as_view(template_name='home.html'), name='home'),
9-
re_path(r"^accounts/login/$", auth_views.LoginView.as_view(template_name='login.html'), name='login'), # noqa
10-
re_path(r"^accounts/logout/$", auth_views.LogoutView.as_view(next_page='/'), name='logout'),
11-
re_path(r"^", include('oidc_provider.urls', namespace='oidc_provider')),
8+
re_path(r"^$", TemplateView.as_view(template_name="home.html"), name="home"),
9+
re_path(
10+
r"^accounts/login/$", auth_views.LoginView.as_view(template_name="login.html"), name="login"
11+
), # noqa
12+
re_path(r"^accounts/logout/$", auth_views.LogoutView.as_view(next_page="/"), name="logout"),
13+
re_path(r"^", include("oidc_provider.urls", namespace="oidc_provider")),
1214
re_path(r"^admin/", admin.site.urls),
1315
]

example/app/wsgi.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from django.core.wsgi import get_wsgi_application
44

5-
6-
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings')
5+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings")
76

87
application = get_wsgi_application()

example/manage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import os
33
import sys
44

5-
if __name__ == '__main__':
6-
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings')
5+
if __name__ == "__main__":
6+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings")
77

88
from django.core.management import execute_from_command_line
99

oidc_provider/admin.py

Lines changed: 55 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,95 +2,112 @@
22
from random import randint
33
from uuid import uuid4
44

5-
from django.forms import ModelForm
65
from django.contrib import admin
6+
from django.forms import ModelForm
77
from django.utils.translation import gettext_lazy as _
88

9-
from oidc_provider.models import Client, Code, Token, RSAKey
9+
from oidc_provider.models import Client
10+
from oidc_provider.models import Code
11+
from oidc_provider.models import RSAKey
12+
from oidc_provider.models import Token
1013

1114

1215
class ClientForm(ModelForm):
13-
1416
class Meta:
1517
model = Client
1618
exclude = []
1719

1820
def __init__(self, *args, **kwargs):
1921
super(ClientForm, self).__init__(*args, **kwargs)
20-
self.fields['client_id'].required = False
21-
self.fields['client_id'].widget.attrs['disabled'] = 'true'
22-
self.fields['client_secret'].required = False
23-
self.fields['client_secret'].widget.attrs['disabled'] = 'true'
22+
self.fields["client_id"].required = False
23+
self.fields["client_id"].widget.attrs["disabled"] = "true"
24+
self.fields["client_secret"].required = False
25+
self.fields["client_secret"].widget.attrs["disabled"] = "true"
2426

2527
def clean_client_id(self):
26-
instance = getattr(self, 'instance', None)
28+
instance = getattr(self, "instance", None)
2729
if instance and instance.pk:
2830
return instance.client_id
2931
else:
3032
return str(randint(1, 999999)).zfill(6)
3133

3234
def clean_client_secret(self):
33-
instance = getattr(self, 'instance', None)
35+
instance = getattr(self, "instance", None)
3436

35-
secret = ''
37+
secret = ""
3638

3739
if instance and instance.pk:
38-
if (self.cleaned_data['client_type'] == 'confidential') and not instance.client_secret:
40+
if (self.cleaned_data["client_type"] == "confidential") and not instance.client_secret:
3941
secret = sha224(uuid4().hex.encode()).hexdigest()
40-
elif (self.cleaned_data['client_type'] == 'confidential') and instance.client_secret:
42+
elif (self.cleaned_data["client_type"] == "confidential") and instance.client_secret:
4143
secret = instance.client_secret
4244
else:
43-
if (self.cleaned_data['client_type'] == 'confidential'):
45+
if self.cleaned_data["client_type"] == "confidential":
4446
secret = sha224(uuid4().hex.encode()).hexdigest()
4547

4648
return secret
4749

4850

4951
@admin.register(Client)
5052
class ClientAdmin(admin.ModelAdmin):
51-
5253
fieldsets = [
53-
[_(u''), {
54-
'fields': (
55-
'name', 'owner', 'client_type', 'response_types', '_redirect_uris', 'jwt_alg',
56-
'require_consent', 'reuse_consent'),
57-
}],
58-
[_(u'Credentials'), {
59-
'fields': ('client_id', 'client_secret', '_scope'),
60-
}],
61-
[_(u'Information'), {
62-
'fields': ('contact_email', 'website_url', 'terms_url', 'logo', 'date_created'),
63-
}],
64-
[_(u'Session Management'), {
65-
'fields': ('_post_logout_redirect_uris',),
66-
}],
54+
[
55+
_(""),
56+
{
57+
"fields": (
58+
"name",
59+
"owner",
60+
"client_type",
61+
"response_types",
62+
"_redirect_uris",
63+
"jwt_alg",
64+
"require_consent",
65+
"reuse_consent",
66+
),
67+
},
68+
],
69+
[
70+
_("Credentials"),
71+
{
72+
"fields": ("client_id", "client_secret", "_scope"),
73+
},
74+
],
75+
[
76+
_("Information"),
77+
{
78+
"fields": ("contact_email", "website_url", "terms_url", "logo", "date_created"),
79+
},
80+
],
81+
[
82+
_("Session Management"),
83+
{
84+
"fields": ("_post_logout_redirect_uris",),
85+
},
86+
],
6787
]
6888
form = ClientForm
69-
list_display = ['name', 'client_id', 'response_type_descriptions', 'date_created']
70-
readonly_fields = ['date_created']
71-
search_fields = ['name']
72-
raw_id_fields = ['owner']
89+
list_display = ["name", "client_id", "response_type_descriptions", "date_created"]
90+
readonly_fields = ["date_created"]
91+
search_fields = ["name"]
92+
raw_id_fields = ["owner"]
7393

7494

7595
@admin.register(Code)
7696
class CodeAdmin(admin.ModelAdmin):
77-
78-
raw_id_fields = ['user']
97+
raw_id_fields = ["user"]
7998

8099
def has_add_permission(self, request):
81100
return False
82101

83102

84103
@admin.register(Token)
85104
class TokenAdmin(admin.ModelAdmin):
86-
87-
raw_id_fields = ['user']
105+
raw_id_fields = ["user"]
88106

89107
def has_add_permission(self, request):
90108
return False
91109

92110

93111
@admin.register(RSAKey)
94112
class RSAKeyAdmin(admin.ModelAdmin):
95-
96-
readonly_fields = ['kid']
113+
readonly_fields = ["kid"]

oidc_provider/apps.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22

33

44
class OIDCProviderConfig(AppConfig):
5-
6-
name = 'oidc_provider'
7-
verbose_name = u'OpenID Connect Provider'
5+
name = "oidc_provider"
6+
verbose_name = "OpenID Connect Provider"

0 commit comments

Comments
 (0)