Skip to content

Commit 95b608f

Browse files
committed
Allow backend to take path or str
1 parent 7ab0cb6 commit 95b608f

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

code_submitter/auth.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
import logging
33
import secrets
44
import binascii
5-
from typing import cast, Dict, List, Tuple, Optional, Sequence
5+
from typing import cast, Dict, List, Tuple, Union, Optional, Sequence
6+
from pathlib import Path
67
from typing_extensions import TypedDict
78

89
import yaml
@@ -217,11 +218,7 @@ class FileBackend(BasicAuthBackend):
217218
UNKNOWN_USER_MESSAGE = "Username or password is incorrect"
218219
BLUESHIRT_TEAM = "SRX"
219220

220-
def __init__(
221-
self,
222-
*,
223-
path: str,
224-
) -> None:
221+
def __init__(self, *, path: Union[str, Path]) -> None:
225222
with open(path) as f:
226223
self.credentials = cast(Dict[str, str], yaml.safe_load(f))
227224

tests/tests_auth.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ class FileAuthTests(test_utils.AsyncTestCase):
106106
def setUp(self) -> None:
107107
super().setUp()
108108

109-
self.auth_fixture = Path(__file__).parent / 'fixtures' / 'auth-file.yml'
110-
111-
self.backend = FileBackend(path=str(self.auth_fixture))
109+
self.backend = FileBackend(
110+
path=Path(__file__).parent / 'fixtures' / 'auth-file.yml'
111+
)
112112

113113
def test_ok(self) -> None:
114114
scopes, user = self.await_(self.backend.validate('ABC', 'password1'))

0 commit comments

Comments
 (0)