diff options
| author | Árni Dagur <arni@dagur.eu> | 2020-09-22 16:35:15 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-22 16:35:15 +0000 |
| commit | 653221ca5463a4e785839bed6142dad04d6a6d6e (patch) | |
| tree | 3d0028be8fdab9daa984534dfe32c0e934425dff | |
| parent | 04678357e0d95ba1569e65b7fc423c17f867a87f (diff) | |
| parent | 1f73df47e5a0fd41b912ba21c5897b4c77401db1 (diff) | |
Merge pull request #13 from ArniDagur/update-to-0.3.2
Update to 0.3.2
| -rw-r--r-- | .github/workflows/ci.yml | 23 | ||||
| -rw-r--r-- | Cargo.toml | 4 | ||||
| -rw-r--r-- | adblock/__init__.py | 5 | ||||
| -rw-r--r-- | pyproject.toml | 2 | ||||
| -rw-r--r-- | src/lib.rs | 2 | ||||
| -rw-r--r-- | tests/test_imports.py | 34 |
6 files changed, 59 insertions, 11 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4071231..141fea4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml | |||
| @@ -39,7 +39,7 @@ jobs: | |||
| 39 | strategy: | 39 | strategy: |
| 40 | fail-fast: false | 40 | fail-fast: false |
| 41 | matrix: | 41 | matrix: |
| 42 | python-version: [3.5, 3.6, 3.7, 3.8] | 42 | python-version: [3.5, 3.6, 3.7, 3.8, 3.9] |
| 43 | os: [ubuntu-latest, macos-latest, windows-latest] | 43 | os: [ubuntu-latest, macos-latest, windows-latest] |
| 44 | exclude: | 44 | exclude: |
| 45 | # There is a known issue where Python C extensions | 45 | # There is a known issue where Python C extensions |
| @@ -53,11 +53,16 @@ jobs: | |||
| 53 | - name: Checkout | 53 | - name: Checkout |
| 54 | uses: actions/checkout@v1 | 54 | uses: actions/checkout@v1 |
| 55 | 55 | ||
| 56 | - name: Set up Python ${{ matrix.python-version }} | 56 | - uses: actions/setup-python@v2 |
| 57 | uses: actions/setup-python@v1 | 57 | if: matrix.python-version != 3.9 |
| 58 | with: | 58 | with: |
| 59 | python-version: ${{ matrix.python-version }} | 59 | python-version: ${{ matrix.python-version }} |
| 60 | 60 | ||
| 61 | - uses: actions/setup-python@v2 | ||
| 62 | if: matrix.python-version == 3.9 | ||
| 63 | with: | ||
| 64 | python-version: '3.9.0-alpha - 3.9.0' | ||
| 65 | |||
| 61 | - name: Install dependencies | 66 | - name: Install dependencies |
| 62 | run: | | 67 | run: | |
| 63 | python -m pip install --upgrade pip | 68 | python -m pip install --upgrade pip |
| @@ -86,7 +91,7 @@ jobs: | |||
| 86 | strategy: | 91 | strategy: |
| 87 | fail-fast: false | 92 | fail-fast: false |
| 88 | matrix: | 93 | matrix: |
| 89 | python-version: [3.5, 3.6, 3.7, 3.8] | 94 | python-version: [3.5, 3.6, 3.7, 3.8, 3.9] |
| 90 | os: [ubuntu-latest, macos-latest, windows-latest] | 95 | os: [ubuntu-latest, macos-latest, windows-latest] |
| 91 | exclude: | 96 | exclude: |
| 92 | # There is a known issue where Python C extensions | 97 | # There is a known issue where Python C extensions |
| @@ -98,10 +103,16 @@ jobs: | |||
| 98 | steps: | 103 | steps: |
| 99 | - uses: actions/checkout@v1 | 104 | - uses: actions/checkout@v1 |
| 100 | 105 | ||
| 101 | - uses: actions/setup-python@v1 | 106 | - uses: actions/setup-python@v2 |
| 107 | if: matrix.python-version != 3.9 | ||
| 102 | with: | 108 | with: |
| 103 | python-version: ${{ matrix.python-version }} | 109 | python-version: ${{ matrix.python-version }} |
| 104 | 110 | ||
| 111 | - uses: actions/setup-python@v2 | ||
| 112 | if: matrix.python-version == 3.9 | ||
| 113 | with: | ||
| 114 | python-version: '3.9.0-alpha - 3.9.0' | ||
| 115 | |||
| 105 | - name: Install latest nightly | 116 | - name: Install latest nightly |
| 106 | uses: actions-rs/toolchain@v1 | 117 | uses: actions-rs/toolchain@v1 |
| 107 | with: | 118 | with: |
| @@ -150,7 +161,7 @@ jobs: | |||
| 150 | 161 | ||
| 151 | docs-publish: | 162 | docs-publish: |
| 152 | runs-on: ubuntu-latest | 163 | runs-on: ubuntu-latest |
| 153 | if: github.ref == 'refs/heads/master' | 164 | if: github.ref == 'refs/heads/master' && github.event.action == 'push' |
| 154 | steps: | 165 | steps: |
| 155 | - uses: actions/checkout@v2 | 166 | - uses: actions/checkout@v2 |
| 156 | with: | 167 | with: |
| @@ -1,7 +1,7 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "adblock" | 2 | name = "adblock" |
| 3 | publish = false | 3 | publish = false |
| 4 | version = "0.3.1" | 4 | version = "0.3.2" |
| 5 | authors = ["Árni Dagur <arni@dagur.eu"] | 5 | authors = ["Árni Dagur <arni@dagur.eu"] |
| 6 | edition = "2018" | 6 | edition = "2018" |
| 7 | license = "MIT OR Apache-2.0" | 7 | license = "MIT OR Apache-2.0" |
| @@ -11,7 +11,7 @@ debug = true | |||
| 11 | 11 | ||
| 12 | [dependencies] | 12 | [dependencies] |
| 13 | adblock = { version = "0.3.2", default-features = false, features = ["full-regex-handling", "embedded-domain-resolver"] } | 13 | adblock = { version = "0.3.2", default-features = false, features = ["full-regex-handling", "embedded-domain-resolver"] } |
| 14 | pyo3 = "0.11" | 14 | pyo3 = "0.12" |
| 15 | 15 | ||
| 16 | [lib] | 16 | [lib] |
| 17 | name = "adblock" | 17 | name = "adblock" |
diff --git a/adblock/__init__.py b/adblock/__init__.py index 28d0665..bb1b6e1 100644 --- a/adblock/__init__.py +++ b/adblock/__init__.py | |||
| @@ -1 +1,4 @@ | |||
| 1 | from .adblock import * | 1 | from .adblock import __version__, Engine, FilterSet, BlockerResult, UrlSpecificResources |
| 2 | |||
| 3 | |||
| 4 | __all__ = ("Engine", "FilterSet", "BlockerResult", "UrlSpecificResources") | ||
diff --git a/pyproject.toml b/pyproject.toml index ab66883..c829e6c 100644 --- a/pyproject.toml +++ b/pyproject.toml | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | [tool.poetry] | 1 | [tool.poetry] |
| 2 | name = "adblock" | 2 | name = "adblock" |
| 3 | version = "0.3.1" | 3 | version = "0.3.2" |
| 4 | description = "Brave's adblocking in Python" | 4 | description = "Brave's adblocking in Python" |
| 5 | authors = ["Árni Dagur <arni@dagur.eu>"] | 5 | authors = ["Árni Dagur <arni@dagur.eu>"] |
| 6 | license = "MIT OR Apache-2.0" | 6 | license = "MIT OR Apache-2.0" |
| @@ -17,7 +17,7 @@ use adblock::engine::Engine as RustEngine; | |||
| 17 | use adblock::lists::FilterFormat; | 17 | use adblock::lists::FilterFormat; |
| 18 | use adblock::lists::FilterSet as RustFilterSet; | 18 | use adblock::lists::FilterSet as RustFilterSet; |
| 19 | use pyo3::class::PyObjectProtocol; | 19 | use pyo3::class::PyObjectProtocol; |
| 20 | use pyo3::exceptions::ValueError as PyValueError; | 20 | use pyo3::exceptions::PyValueError; |
| 21 | use pyo3::prelude::*; | 21 | use pyo3::prelude::*; |
| 22 | use pyo3::types::PyBytes; | 22 | use pyo3::types::PyBytes; |
| 23 | use pyo3::PyErr; | 23 | use pyo3::PyErr; |
diff --git a/tests/test_imports.py b/tests/test_imports.py new file mode 100644 index 0000000..7692483 --- /dev/null +++ b/tests/test_imports.py | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | import re | ||
| 2 | import adblock | ||
| 3 | |||
| 4 | |||
| 5 | def get_added_classes(): | ||
| 6 | """ | ||
| 7 | Try to get the names of all classes that we added to the Python module | ||
| 8 | from Rust. As always, we unfortunately don't have access to the Rust AST | ||
| 9 | so we have to make do with regular expressions. | ||
| 10 | """ | ||
| 11 | classes = [] | ||
| 12 | with open("src/lib.rs", "r", encoding="utf-8") as rs_f: | ||
| 13 | for line in rs_f: | ||
| 14 | match = re.match(r"m\.add_class::<(.+)>\(\)\?;", line.strip()) | ||
| 15 | if match is not None: | ||
| 16 | classes.append(match.group(1)) | ||
| 17 | return classes | ||
| 18 | |||
| 19 | |||
| 20 | def test_added_classes(): | ||
| 21 | """ | ||
| 22 | Make sure that there's no class that we added in Rust but didn't import in | ||
| 23 | `__init__.py` and vice versa. | ||
| 24 | """ | ||
| 25 | added_classes = get_added_classes() | ||
| 26 | assert added_classes == list(adblock.__all__) | ||
| 27 | |||
| 28 | |||
| 29 | def test_dunder_all_classes_imported(): | ||
| 30 | """ | ||
| 31 | Make sure that there's no class in `__all__` that we haven't imported. | ||
| 32 | """ | ||
| 33 | for c in adblock.__all__: | ||
| 34 | assert hasattr(adblock, c) | ||
