Skip to content

Commit eba524f

Browse files
Added typing stuff
1 parent 391625c commit eba524f

File tree

5 files changed

+74
-13
lines changed

5 files changed

+74
-13
lines changed

MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include hibpwned/py.typed

hibpwned/__init__.py

+9-11
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@
1717
import hashlib
1818
import requests
1919

20+
ReturnAlias = int | list[dict[str, str | int | bool]]
21+
22+
AltReturnAlias = int | list[dict[str, str | int | bool]] | list[str]
23+
24+
DataAlias = list[dict[str, str | int | bool]] | dict[str, str | int | bool]
25+
26+
AltDataAlias = (list[dict[str, str | int | bool]]
27+
| dict[str, str | int | bool] | list[str])
28+
2029

2130
def _check(resp: requests.models.Response) -> None:
2231
"""Helper function to check the response code and prints anything
@@ -196,15 +205,6 @@ class Pwned:
196205
>>> foo = Pwned("[email protected]", "My_App", "My_API_Key")
197206
>>> data = foo.search_password("BadPassword")
198207
"""
199-
ReturnAlias = (int | list[dict[str, str | int | bool]])
200-
201-
AltReturnAlias = (int | list[dict[str, str | int | bool]] | list[str])
202-
203-
DataAlias = (list[dict[str, str | int | bool]]
204-
| dict[str, str | int | bool])
205-
AltDataAlias = (list[dict[str, str | int | bool]]
206-
| dict[str, str | int | bool] | list[str])
207-
208208
url: str
209209
resp: requests.models.Response
210210
truncate_string: str
@@ -229,7 +229,6 @@ def __init__(self, account: str, agent: str, key: str) -> None:
229229
}
230230
self.timeout = 300
231231

232-
# pylint: disable=undefined-variable
233232
def search_all_breaches(self,
234233
truncate: bool | None = False,
235234
domain: str | None = None,
@@ -296,7 +295,6 @@ def search_all_breaches(self,
296295
return alt_data
297296
return resp.status_code
298297

299-
# pylint: disable=undefined-variable
300298
def all_breaches(self, domain: str | None = None) -> ReturnAlias:
301299
"""Retrieves all breached sites from the system. The result set
302300
can also be filtered by domain by passing the argument

hibpwned/__init__.pyi

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
"""__init__.pyi"""
2+
3+
from __future__ import annotations
4+
import requests
5+
6+
ReturnAlias = int | list[dict[str, str | int | bool]]
7+
8+
AltReturnAlias = int | list[dict[str, str | int | bool]] | list[str]
9+
10+
DataAlias = list[dict[str, str | int | bool]] | dict[str, str | int | bool]
11+
12+
AltDataAlias = (list[dict[str, str | int | bool]]
13+
| dict[str, str | int | bool] | list[str])
14+
15+
16+
def _check(resp: requests.models.Response) -> None:
17+
...
18+
19+
20+
class Pwned:
21+
22+
url: str
23+
resp: requests.models.Response
24+
truncate_string: str
25+
domain_string: str
26+
unverified_string: str
27+
classes: list[str]
28+
hashes: str
29+
hash_list: list[str]
30+
hexdig: str
31+
hsh: str
32+
pnum: str
33+
data: DataAlias
34+
alt_data: AltDataAlias
35+
36+
def __init__(self, account: str, agent: str, key: str) -> None:
37+
...
38+
39+
def search_all_breaches(self,
40+
truncate: bool | None = False,
41+
domain: str | None = None,
42+
unverified: bool | None = False) -> AltReturnAlias:
43+
...
44+
45+
def all_breaches(self, domain: str | None = None) -> ReturnAlias:
46+
...
47+
48+
def single_breach(self, name: str) -> ReturnAlias:
49+
...
50+
51+
def data_classes(self) -> int | list[str]:
52+
...
53+
54+
def search_pastes(self) -> ReturnAlias:
55+
...
56+
57+
def search_password(self, password: str) -> int | str:
58+
...
59+
60+
def search_hashes(self, hsh: str) -> int | str:
61+
...

hibpwned/py.typed

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Marker file for PEP 561.

pyproject.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "hibpwned"
7-
version = "1.3.8"
7+
version = "1.3.9"
88
authors = [
99
{ name="plasticuproject", email="[email protected]" },
1010
]
@@ -15,7 +15,7 @@ requires-python = ">=3.11"
1515
classifiers = [
1616
"Programming Language :: Python :: 3",
1717
"Development Status :: 5 - Production/Stable", "Intended Audience :: Developers",
18-
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
18+
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
1919
"Operating System :: OS Independent",
2020
"Topic :: Utilities", "Topic :: Utilities"
2121
]

0 commit comments

Comments
 (0)