Skip to content

Commit 2c65008

Browse files
authored
Merge pull request #5298 from pierwill/pierwill-type-syntax-2
Update syntax for existing type annotations
2 parents 309f17e + 0a3c60d commit 2c65008

File tree

8 files changed

+101
-130
lines changed

8 files changed

+101
-130
lines changed

securedrop/crypto_util.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ def do_runtime_tests(self):
135135
if not rm.check_secure_delete_capability():
136136
raise AssertionError("Secure file deletion is not possible.")
137137

138-
def get_wordlist(self, locale):
139-
# type: (Text) -> List[str]
138+
def get_wordlist(self, locale: 'Text') -> 'List[str]':
140139
"""" Ensure the wordlist for the desired locale is read and available
141140
in the words global variable. If there is no wordlist for the
142141
desired local, fallback to the default english wordlist.

securedrop/journalist_app/__init__.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@
3838
_insecure_views = ['main.login', 'main.select_logo', 'static']
3939

4040

41-
def create_app(config):
42-
# type: (SDConfig) -> Flask
41+
def create_app(config: 'SDConfig') -> Flask:
4342
app = Flask(__name__,
4443
template_folder=config.JOURNALIST_TEMPLATES_DIR,
4544
static_folder=path.join(config.SECUREDROP_ROOT, 'static'))
@@ -82,16 +81,16 @@ def create_app(config):
8281
)
8382

8483
@app.errorhandler(CSRFError)
85-
def handle_csrf_error(e):
86-
# type: (CSRFError) -> Response
84+
def handle_csrf_error(e: CSRFError) -> 'Response':
8785
# render the message first to ensure it's localized.
8886
msg = gettext('You have been logged out due to inactivity')
8987
session.clear()
9088
flash(msg, 'error')
9189
return redirect(url_for('main.login'))
9290

93-
def _handle_http_exception(error):
94-
# type: (HTTPException) -> Tuple[Union[Response, str], Optional[int]]
91+
def _handle_http_exception(
92+
error: 'HTTPException'
93+
) -> 'Tuple[Union[Response, str], Optional[int]]':
9594
# Workaround for no blueprint-level 404/5 error handlers, see:
9695
# https://github.com/pallets/flask/issues/503#issuecomment-71383286
9796
handler = list(app.error_handler_spec['api'][error.code].values())[0]
@@ -129,8 +128,7 @@ def load_instance_config():
129128
app.instance_config = InstanceConfig.get_current()
130129

131130
@app.before_request
132-
def setup_g():
133-
# type: () -> Optional[Response]
131+
def setup_g() -> 'Optional[Response]':
134132
"""Store commonly used values in Flask's special g object"""
135133
if 'expires' in session and datetime.utcnow() >= session['expires']:
136134
session.clear()

securedrop/journalist_app/utils.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
from sdconfig import SDConfig # noqa: F401
2828

2929

30-
def logged_in():
31-
# type: () -> bool
30+
def logged_in() -> bool:
3231
# When a user is logged in, we push their user ID (database primary key)
3332
# into the session. setup_g checks for this value, and if it finds it,
3433
# stores a reference to the user's Journalist object in g.
@@ -255,8 +254,7 @@ def col_delete(cols_selected):
255254
return redirect(url_for('main.index'))
256255

257256

258-
def make_password(config):
259-
# type: (SDConfig) -> str
257+
def make_password(config: 'SDConfig') -> str:
260258
while True:
261259
password = current_app.crypto_util.genrandomid(
262260
7,

0 commit comments

Comments
 (0)