|
| 1 | +from __future__ import annotations |
| 2 | + |
| 3 | +from typing import Optional |
| 4 | + |
1 | 5 | import requests |
2 | 6 | from requests import Response, exceptions |
3 | 7 |
|
@@ -34,9 +38,24 @@ def verbose_raise_for_status(response: Response) -> Response: |
34 | 38 | class BaseRepository: |
35 | 39 | """Base repository for interacting with the Doccano API""" |
36 | 40 |
|
37 | | - def __init__(self, base_url: str) -> None: |
| 41 | + def __init__(self, base_url: str, verify: Optional[str | bool] = None) -> None: |
| 42 | + """Initialize the repository with the base url |
| 43 | +
|
| 44 | + Args: |
| 45 | + base_url (str): The base url of the Doccano instance |
| 46 | + verify (str | bool): Either a boolean, in which case it controls whether we verify |
| 47 | + the server's TLS certificate, or a string, in which case it must be a path |
| 48 | + to a CA bundle to use. Defaults to ``True``. When set to |
| 49 | + ``False``, requests will accept any TLS certificate presented by |
| 50 | + the server, and will ignore hostname mismatches and/or expired |
| 51 | + certificates, which will make your application vulnerable to |
| 52 | + man-in-the-middle (MitM) attacks. Setting verify to ``False`` |
| 53 | + may be useful during local development or testing. |
| 54 | + """ |
38 | 55 | self._base_url = base_url |
39 | 56 | self._session = requests.Session() |
| 57 | + if verify is not None: |
| 58 | + self._session.verify = verify |
40 | 59 | headers = { |
41 | 60 | "content-type": "application/json", |
42 | 61 | "accept": "application/json", |
|
0 commit comments