Skip to content

Commit 77a2bda

Browse files
committed
fix: format and lint
1 parent 23f91e2 commit 77a2bda

File tree

10 files changed

+117
-90
lines changed

10 files changed

+117
-90
lines changed

.pylintrc

Lines changed: 16 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ persistent=yes
1616

1717
# List of plugins (as comma separated values of python modules names) to load,
1818
# usually to register additional checkers.
19-
load-plugins=
19+
#load-plugins=
2020

2121
# Use multiple processes to speed up Pylint.
2222
jobs=1
@@ -28,14 +28,14 @@ unsafe-load-any-extension=no
2828
# A comma-separated list of package or module names from where C extensions may
2929
# be loaded. Extensions are loading into the active Python interpreter and may
3030
# run arbitrary code
31-
extension-pkg-whitelist=
31+
#extension-pkg-whitelist=
3232

3333

3434
[MESSAGES CONTROL]
3535

3636
# Only show warnings with the listed confidence levels. Leave empty to show
3737
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
38-
confidence=
38+
#confidence=
3939

4040
# Enable the message, report, category or checker with the given id(s). You can
4141
# either give multiple identifier separated by comma (,) or put this option
@@ -62,12 +62,11 @@ disable=
6262
too-few-public-methods,
6363
no-member,
6464
too-many-format-args,
65-
bad-continuation,
6665
bare-except,
6766
inconsistent-return-statements,
6867
no-name-in-module,
6968
cyclic-import,
70-
unnecessary-pass,
69+
unnecessary-pass
7170

7271

7372
[REPORTS]
@@ -77,11 +76,6 @@ disable=
7776
# mypackage.mymodule.MyReporterClass.
7877
output-format=text
7978

80-
# Put messages in a separate file for each module / package specified on the
81-
# command line instead of printing them on stdout. Reports (if any) will be
82-
# written in a file name "pylint_global.[txt|html]".
83-
files-output=no
84-
8579
# Tells whether to display a full report or only the messages
8680
reports=no
8781

@@ -136,7 +130,7 @@ dummy-variables-rgx=_$|dummy
136130

137131
# List of additional names supposed to be defined in builtins. Remember that
138132
# you should avoid to define new builtins when possible.
139-
additional-builtins=
133+
#additional-builtins=
140134

141135
# List of strings which can identify a callback function by name. A callback
142136
# name must start or end with one of those strings.
@@ -155,9 +149,6 @@ ignore-long-lines=^\s*(# )?<?https?://\S+>?$
155149
# else.
156150
single-line-if-stmt=no
157151

158-
# List of optional constructs for which whitespace checking is disabled
159-
no-space-check=trailing-comma,dict-separator
160-
161152
# Maximum number of lines in a module
162153
max-module-lines=2000
163154

@@ -169,14 +160,11 @@ indent-string=' '
169160
indent-after-paren=4
170161

171162
# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
172-
expected-line-ending-format=
163+
#expected-line-ending-format=
173164

174165

175166
[BASIC]
176167

177-
# List of builtins function names that should not be used, separated by a comma
178-
bad-functions=map,filter,input
179-
180168
# Good variable names which should always be accepted, separated by a comma
181169
good-names=i,j,k,ex,Run,_
182170

@@ -185,71 +173,41 @@ bad-names=foo,bar,baz,toto,tutu,tata
185173

186174
# Colon-delimited sets of names that determine each other's naming style when
187175
# the name regexes allow several styles.
188-
name-group=
176+
#name-group=
189177

190178
# Include a hint for the correct naming format with invalid-name
191179
include-naming-hint=no
192180

193181
# Regular expression matching correct function names
194182
function-rgx=[a-z_][a-z0-9_]{2,30}$
195183

196-
# Naming hint for function names
197-
function-name-hint=[a-z_][a-z0-9_]{2,30}$
198-
199184
# Regular expression matching correct variable names
200185
variable-rgx=[a-z_][a-z0-9_]{2,30}$
201186

202-
# Naming hint for variable names
203-
variable-name-hint=[a-z_][a-z0-9_]{2,30}$
204-
205187
# Regular expression matching correct constant names
206188
const-rgx=[a-z_][a-z0-9_]{2,30}$
207189

208-
# Naming hint for constant names
209-
const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$
210-
211190
# Regular expression matching correct attribute names
212191
attr-rgx=[a-z_][a-z0-9_]{2,30}$
213192

214-
# Naming hint for attribute names
215-
attr-name-hint=[a-z_][a-z0-9_]{2,30}$
216-
217193
# Regular expression matching correct argument names
218194
argument-rgx=[a-z_][a-z0-9_]{2,30}$
219195

220-
# Naming hint for argument names
221-
argument-name-hint=[a-z_][a-z0-9_]{2,30}$
222-
223196
# Regular expression matching correct class attribute names
224197
class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
225198

226-
# Naming hint for class attribute names
227-
class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
228-
229199
# Regular expression matching correct inline iteration names
230200
inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
231201

232-
# Naming hint for inline iteration names
233-
inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$
234-
235202
# Regular expression matching correct class names
236203
class-rgx=[A-Z_][a-zA-Z0-9]+$
237204

238-
# Naming hint for class names
239-
class-name-hint=[A-Z_][a-zA-Z0-9]+$
240-
241205
# Regular expression matching correct module names
242206
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
243207

244-
# Naming hint for module names
245-
module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
246-
247208
# Regular expression matching correct method names
248209
method-rgx=[a-z_][a-z0-9_]{2,30}$
249210

250-
# Naming hint for method names
251-
method-name-hint=[a-z_][a-z0-9_]{2,30}$
252-
253211
# Regular expression which should only match function or class names that do
254212
# not require a docstring.
255213
no-docstring-rgx=__.*__
@@ -271,11 +229,11 @@ ignore-mixin-members=yes
271229
# List of module names for which member attributes should not be checked
272230
# (useful for modules/projects where namespaces are manipulated during runtime
273231
# and thus existing member attributes cannot be deduced by static analysis
274-
ignored-modules=
232+
#ignored-modules=
275233

276234
# List of classes names for which member attributes should not be checked
277235
# (useful for classes with attributes dynamically set).
278-
ignored-classes=SQLObject, optparse.Values, thread._local, _thread._local
236+
ignored-classes=SQLObject,optparse.Values,thread._local,_thread._local
279237

280238
# List of members which are set dynamically and missed by pylint inference
281239
# system, and so shouldn't trigger E1101 when accessed. Python regular
@@ -291,13 +249,13 @@ contextmanager-decorators=contextlib.contextmanager
291249

292250
# Spelling dictionary name. Available dictionaries: none. To make it working
293251
# install python-enchant package.
294-
spelling-dict=
252+
#spelling-dict=
295253

296254
# List of comma separated words that should not be checked.
297-
spelling-ignore-words=
255+
#spelling-ignore-words=
298256

299257
# A path to a file that contains private dictionary; one word per line.
300-
spelling-private-dict-file=
258+
#spelling-private-dict-file=
301259

302260
# Tells whether to store unknown words to indicated private dictionary in
303261
# --spelling-private-dict-file option instead of raising a message.
@@ -361,19 +319,19 @@ deprecated-modules=regsub,TERMIOS,Bastion,rexec
361319

362320
# Create a graph of every (i.e. internal and external) dependencies in the
363321
# given file (report RP0402 must not be disabled)
364-
import-graph=
322+
#import-graph=
365323

366324
# Create a graph of external dependencies in the given file (report RP0402 must
367325
# not be disabled)
368-
ext-import-graph=
326+
#ext-import-graph=
369327

370328
# Create a graph of internal dependencies in the given file (report RP0402 must
371329
# not be disabled)
372-
int-import-graph=
330+
#int-import-graph=
373331

374332

375333
[EXCEPTIONS]
376334

377335
# Exceptions that will emit a warning when being caught. Defaults to
378336
# "Exception"
379-
overgeneral-exceptions=Exception
337+
overgeneral-exceptions=builtins.Exception

requirements.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ pyotp~=2.9.0
1616
passlib~=1.7.4
1717
xkcdpass~=1.20.0
1818
gunicorn~=23.0.0
19+
black~=25.12.0
20+
pylint~=4.0.4

requirements.txt

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@ annotated-types==0.7.0
1818
# via pydantic
1919
anyio==4.12.0
2020
# via httpx
21+
astroid==4.0.2
22+
# via pylint
2123
async-property==0.2.2
2224
# via python-keycloak
2325
attrs==25.4.0
2426
# via aiohttp
27+
black==25.12.0
28+
# via -r requirements.in
2529
blinker==1.9.0
2630
# via
2731
# flask
@@ -37,7 +41,9 @@ cffi==2.0.0
3741
charset-normalizer==3.4.4
3842
# via requests
3943
click==8.3.1
40-
# via flask
44+
# via
45+
# black
46+
# flask
4147
cryptography==46.0.3
4248
# via
4349
# jwcrypto
@@ -50,6 +56,8 @@ deprecated==1.3.1
5056
# via limits
5157
deprecation==2.1.0
5258
# via python-keycloak
59+
dill==0.4.0
60+
# via pylint
5361
dnspython==2.8.0
5462
# via srvlookup
5563
flask==3.1.2
@@ -100,6 +108,8 @@ idna==3.11
100108
# yarl
101109
importlib-resources==6.5.2
102110
# via flask-pyoidc
111+
isort==7.0.0
112+
# via pylint
103113
itsdangerous==2.2.0
104114
# via flask
105115
jinja2==3.1.6
@@ -120,23 +130,34 @@ markupsafe==3.0.3
120130
# mako
121131
# sentry-sdk
122132
# werkzeug
133+
mccabe==0.7.0
134+
# via pylint
123135
multidict==6.7.0
124136
# via
125137
# aiohttp
126138
# yarl
139+
mypy-extensions==1.1.0
140+
# via black
127141
oic==1.6.1
128142
# via flask-pyoidc
129143
ordered-set==4.1.0
130144
# via flask-limiter
131145
packaging==25.0
132146
# via
147+
# black
133148
# deprecation
134149
# gunicorn
135150
# limits
136151
passlib==1.7.4
137152
# via -r requirements.in
153+
pathspec==0.12.1
154+
# via black
138155
pillow==12.0.0
139156
# via flask-qrcode
157+
platformdirs==4.5.1
158+
# via
159+
# black
160+
# pylint
140161
propcache==0.4.1
141162
# via
142163
# aiohttp
@@ -165,6 +186,8 @@ pyjwkest==1.4.4
165186
# via oic
166187
pyjwt==2.10.1
167188
# via twilio
189+
pylint==4.0.4
190+
# via -r requirements.in
168191
pyotp==2.9.0
169192
# via -r requirements.in
170193
python-dotenv==1.2.1
@@ -175,6 +198,8 @@ python-keycloak==5.8.1
175198
# via -r requirements.in
176199
python-ldap==3.4.5
177200
# via csh-ldap
201+
pytokens==0.3.0
202+
# via black
178203
qrcode==8.2
179204
# via flask-qrcode
180205
requests==2.32.5
@@ -201,6 +226,8 @@ srvlookup==3.0.0
201226
# via
202227
# -r requirements.in
203228
# csh-ldap
229+
tomlkit==0.13.3
230+
# via pylint
204231
twilio==9.9.0
205232
# via -r requirements.in
206233
typing-extensions==4.15.0

selfservice/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979
limiter = Limiter(
8080
get_remote_address, app=app, default_limits=["50 per day", "10 per hour"]
8181
)
82+
else:
83+
limiter = Limiter(get_remote_address, app=app, default_limits=[])
8284

8385
# Initialize QR Code Generator
8486
qr = QRcode(app)

selfservice/blueprints/otp.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
)
2121
from selfservice.utilities.ldap import create_ipa_otp, has_ipa_otp, delete_ipa_otp
2222
from selfservice.utilities.app_passwd import set_app_passwd, delete_app_passwd
23-
from selfservice import version, auth, db, OIDC_PROVIDER
23+
from selfservice import version, auth, OIDC_PROVIDER
2424

2525
otp_bp = Blueprint("otp", __name__)
2626

@@ -44,37 +44,49 @@ def enable():
4444

4545
# If its registered in one place but not the other
4646
if kc_registered != ipa_registered:
47-
LOG.warn(f"{username} does not have TOTP in both Keycloak and LDAP (kc_registered={kc_registered}, ipa_registered={ipa_registered})")
47+
LOG.warning(
48+
"%s does not have TOTP in both Keycloak and LDAP "
49+
"(kc_registered=%s, ipa_registered=%s)",
50+
username,
51+
kc_registered,
52+
ipa_registered,
53+
)
4854

4955
# If already registered *somewhere*
5056
if kc_registered or ipa_registered:
5157
return render_template("otp.html", version=version, configured=True)
5258

5359
secret = generate_kc_otp(username)
5460
otp_uri = pyotp.totp.TOTP(secret).provisioning_uri(
55-
"{}@csh.rit.edu".format(username), issuer_name="CSH"
61+
f"{username}@csh.rit.edu", issuer_name="CSH"
5662
)
5763

5864
return render_template(
5965
"otp.html", version=version, otp_uri=otp_uri, secret=secret
6066
)
6167

6268
otp_uri = pyotp.totp.TOTP(secret).provisioning_uri(
63-
"{}@csh.rit.edu".format(username), issuer_name="CSH"
69+
f"{username}@csh.rit.edu", issuer_name="CSH"
6470
)
6571
if not secret:
6672
flash("Invalid secret provided. Please try again.")
6773
return redirect("/otp")
6874
if not otp_code:
69-
flash("No one time password provided. Please scan the code and try again.")
75+
flash(
76+
"One time password provided did not match expected value. "
77+
"Please scan the code and try again."
78+
)
7079
return render_template(
7180
"otp.html", version=version, otp_uri=otp_uri, secret=secret
7281
)
7382

7483
try:
7584
register_kc_otp(username, secret, otp_code)
7685
except OTPInvalidCode:
77-
flash("One time password provided did not match expected value. Please scan the code and try again.")
86+
flash(
87+
"One time password provided did not match expected value."
88+
"Please scan the code and try again."
89+
)
7890
return render_template(
7991
"otp.html", version=version, otp_uri=otp_uri, secret=secret
8092
)

0 commit comments

Comments
 (0)