Skip to content

Commit

Permalink
Added typing stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
plasticuproject committed Sep 1, 2024
1 parent 391625c commit eba524f
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 13 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include hibpwned/py.typed
20 changes: 9 additions & 11 deletions hibpwned/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
import hashlib
import requests

ReturnAlias = int | list[dict[str, str | int | bool]]

AltReturnAlias = int | list[dict[str, str | int | bool]] | list[str]

DataAlias = list[dict[str, str | int | bool]] | dict[str, str | int | bool]

AltDataAlias = (list[dict[str, str | int | bool]]
| dict[str, str | int | bool] | list[str])


def _check(resp: requests.models.Response) -> None:
"""Helper function to check the response code and prints anything
Expand Down Expand Up @@ -196,15 +205,6 @@ class Pwned:
>>> foo = Pwned("test@example.com", "My_App", "My_API_Key")
>>> data = foo.search_password("BadPassword")
"""
ReturnAlias = (int | list[dict[str, str | int | bool]])

AltReturnAlias = (int | list[dict[str, str | int | bool]] | list[str])

DataAlias = (list[dict[str, str | int | bool]]
| dict[str, str | int | bool])
AltDataAlias = (list[dict[str, str | int | bool]]
| dict[str, str | int | bool] | list[str])

url: str
resp: requests.models.Response
truncate_string: str
Expand All @@ -229,7 +229,6 @@ def __init__(self, account: str, agent: str, key: str) -> None:
}
self.timeout = 300

# pylint: disable=undefined-variable
def search_all_breaches(self,
truncate: bool | None = False,
domain: str | None = None,
Expand Down Expand Up @@ -296,7 +295,6 @@ def search_all_breaches(self,
return alt_data
return resp.status_code

# pylint: disable=undefined-variable
def all_breaches(self, domain: str | None = None) -> ReturnAlias:
"""Retrieves all breached sites from the system. The result set
can also be filtered by domain by passing the argument
Expand Down
61 changes: 61 additions & 0 deletions hibpwned/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"""__init__.pyi"""

from __future__ import annotations
import requests

ReturnAlias = int | list[dict[str, str | int | bool]]

AltReturnAlias = int | list[dict[str, str | int | bool]] | list[str]

DataAlias = list[dict[str, str | int | bool]] | dict[str, str | int | bool]

AltDataAlias = (list[dict[str, str | int | bool]]
| dict[str, str | int | bool] | list[str])


def _check(resp: requests.models.Response) -> None:
...


class Pwned:

url: str
resp: requests.models.Response
truncate_string: str
domain_string: str
unverified_string: str
classes: list[str]
hashes: str
hash_list: list[str]
hexdig: str
hsh: str
pnum: str
data: DataAlias
alt_data: AltDataAlias

def __init__(self, account: str, agent: str, key: str) -> None:
...

def search_all_breaches(self,
truncate: bool | None = False,
domain: str | None = None,
unverified: bool | None = False) -> AltReturnAlias:
...

def all_breaches(self, domain: str | None = None) -> ReturnAlias:
...

def single_breach(self, name: str) -> ReturnAlias:
...

def data_classes(self) -> int | list[str]:
...

def search_pastes(self) -> ReturnAlias:
...

def search_password(self, password: str) -> int | str:
...

def search_hashes(self, hsh: str) -> int | str:
...
1 change: 1 addition & 0 deletions hibpwned/py.typed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Marker file for PEP 561.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "hibpwned"
version = "1.3.8"
version = "1.3.9"
authors = [
{ name="plasticuproject", email="plasticuproject@pm.me" },
]
Expand All @@ -15,7 +15,7 @@ requires-python = ">=3.11"
classifiers = [
"Programming Language :: Python :: 3",
"Development Status :: 5 - Production/Stable", "Intended Audience :: Developers",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Operating System :: OS Independent",
"Topic :: Utilities", "Topic :: Utilities"
]
Expand Down

0 comments on commit eba524f

Please sign in to comment.