diff options
| author | Árni Dagur <arni@dagur.eu> | 2020-06-21 16:41:21 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-21 16:41:21 -0400 |
| commit | 4bb4cb4e6c49226740e80a8dd1639274e0719b53 (patch) | |
| tree | 62c3fe064a8bc39bc694bf22b80c7c1e3b755865 | |
| parent | 26b2ffa2e7d1970c30af5d9e97530575916fe769 (diff) | |
Add type stubs to project (#7)
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | adblock/__init__.py | 1 | ||||
| -rw-r--r-- | adblock/adblock.pyi | 78 | ||||
| -rw-r--r-- | adblock/py.typed | 0 | ||||
| -rw-r--r-- | tests/test_engine.py | 1 |
5 files changed, 81 insertions, 0 deletions
| @@ -121,6 +121,7 @@ share/python-wheels/ | |||
| 121 | .installed.cfg | 121 | .installed.cfg |
| 122 | *.egg | 122 | *.egg |
| 123 | MANIFEST | 123 | MANIFEST |
| 124 | *.so | ||
| 124 | 125 | ||
| 125 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow | 126 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow |
| 126 | __pypackages__/ | 127 | __pypackages__/ |
diff --git a/adblock/__init__.py b/adblock/__init__.py new file mode 100644 index 0000000..28d0665 --- /dev/null +++ b/adblock/__init__.py | |||
| @@ -0,0 +1 @@ | |||
| from .adblock import * | |||
diff --git a/adblock/adblock.pyi b/adblock/adblock.pyi new file mode 100644 index 0000000..50a61e8 --- /dev/null +++ b/adblock/adblock.pyi | |||
| @@ -0,0 +1,78 @@ | |||
| 1 | from typing import Optional, Dict, List, Set | ||
| 2 | |||
| 3 | class BlockerResult: | ||
| 4 | matched: bool | ||
| 5 | explicit_cancel: bool | ||
| 6 | important: bool | ||
| 7 | redirect: Optional[str] | ||
| 8 | exception: Optional[str] | ||
| 9 | filter: Optional[str] | ||
| 10 | error: Optional[str] | ||
| 11 | def __repr__(self) -> str: | ||
| 12 | pass | ||
| 13 | |||
| 14 | class HostnameSpecificResources: | ||
| 15 | hide_selectors: Set[str] | ||
| 16 | style_selectors: Dict[str, List[str]] | ||
| 17 | exceptions: Set[str] | ||
| 18 | injected_script: str | ||
| 19 | def __repr__(self) -> str: | ||
| 20 | pass | ||
| 21 | |||
| 22 | class Engine: | ||
| 23 | def __init__( | ||
| 24 | self, | ||
| 25 | network_filters: Optional[List[str]] = None, | ||
| 26 | load_network: bool = True, | ||
| 27 | load_cosmetic: bool = False, | ||
| 28 | debug: bool = False, | ||
| 29 | ) -> None: | ||
| 30 | pass | ||
| 31 | def check_network_urls( | ||
| 32 | self, url: str, source_url: str, request_type: str | ||
| 33 | ) -> BlockerResult: | ||
| 34 | pass | ||
| 35 | def check_network_urls_with_hostnames( | ||
| 36 | self, | ||
| 37 | url: str, | ||
| 38 | hostname: str, | ||
| 39 | source_hostname: str, | ||
| 40 | request_type: str, | ||
| 41 | third_party_request: Optional[bool], | ||
| 42 | ) -> BlockerResult: | ||
| 43 | pass | ||
| 44 | def check_network_urls_with_hostnames_subset( | ||
| 45 | self, | ||
| 46 | url: str, | ||
| 47 | hostname: str, | ||
| 48 | source_hostname: str, | ||
| 49 | request_type: str, | ||
| 50 | third_party_request: Optional[bool], | ||
| 51 | previously_matched_rule: bool, | ||
| 52 | force_check_exceptions: bool, | ||
| 53 | ) -> BlockerResult: | ||
| 54 | pass | ||
| 55 | def serialize(self) -> bytes: | ||
| 56 | pass | ||
| 57 | def serialize_to_file(self, file: str) -> None: | ||
| 58 | pass | ||
| 59 | def deserialize(self, serialized: bytes) -> None: | ||
| 60 | pass | ||
| 61 | def deserialize_from_file(self, file: str) -> None: | ||
| 62 | pass | ||
| 63 | def add_filter_list(self, filter_list: str) -> None: | ||
| 64 | pass | ||
| 65 | def filter_exists(self, filter: str) -> bool: | ||
| 66 | pass | ||
| 67 | def tags_enable(self, tags: List[str]) -> None: | ||
| 68 | pass | ||
| 69 | def tags_disable(self, tags: List[str]) -> None: | ||
| 70 | pass | ||
| 71 | def tag_exists(self, tag: str) -> bool: | ||
| 72 | pass | ||
| 73 | def hostname_cosmetic_resources(self, hostname: str) -> HostnameSpecificResources: | ||
| 74 | pass | ||
| 75 | def hidden_class_id_selectors( | ||
| 76 | self, classes: List[str], ids: List[str], exceptions: Set[str] | ||
| 77 | ) -> List[str]: | ||
| 78 | pass | ||
diff --git a/adblock/py.typed b/adblock/py.typed new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/adblock/py.typed | |||
diff --git a/tests/test_engine.py b/tests/test_engine.py index 602d794..af15b6d 100644 --- a/tests/test_engine.py +++ b/tests/test_engine.py | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | import adblock | 1 | import adblock |
| 2 | 2 | ||
| 3 | |||
| 3 | def test_engine_arguments(): | 4 | def test_engine_arguments(): |
| 4 | # None of these should panic | 5 | # None of these should panic |
| 5 | adblock.Engine() | 6 | adblock.Engine() |
