From b2805edbffb8f8c09558338244e93bde74e3ec77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81rni=20Dagur?= Date: Tue, 22 Sep 2020 05:20:17 +0000 Subject: Avoid using star import in __init__.py --- adblock/__init__.py | 5 ++++- tests/test_imports.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/test_imports.py 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 @@ -from .adblock import * +from .adblock import __version__, Engine, FilterSet, BlockerResult, UrlSpecificResources + + +__all__ = ("Engine", "FilterSet", "BlockerResult", "UrlSpecificResources") 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 @@ +import re +import adblock + + +def get_added_classes(): + """ + Try to get the names of all classes that we added to the Python module + from Rust. As always, we unfortunately don't have access to the Rust AST + so we have to make do with regular expressions. + """ + classes = [] + with open("src/lib.rs", "r", encoding="utf-8") as rs_f: + for line in rs_f: + match = re.match(r"m\.add_class::<(.+)>\(\)\?;", line.strip()) + if match is not None: + classes.append(match.group(1)) + return classes + + +def test_added_classes(): + """ + Make sure that there's no class that we added in Rust but didn't import in + `__init__.py` and vice versa. + """ + added_classes = get_added_classes() + assert added_classes == list(adblock.__all__) + + +def test_dunder_all_classes_imported(): + """ + Make sure that there's no class in `__all__` that we haven't imported. + """ + for c in adblock.__all__: + assert hasattr(adblock, c) -- cgit v1.2.3 From a0b715e146ab3cd5aad428955be45eed1671545f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81rni=20Dagur?= Date: Tue, 22 Sep 2020 05:22:28 +0000 Subject: Build Python 3.9 wheels --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4071231..c60acd2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.5, 3.6, 3.7, 3.8] + python-version: [3.5, 3.6, 3.7, 3.8, 3.9] os: [ubuntu-latest, macos-latest, windows-latest] exclude: # There is a known issue where Python C extensions @@ -86,7 +86,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.5, 3.6, 3.7, 3.8] + python-version: [3.5, 3.6, 3.7, 3.8, 3.9] os: [ubuntu-latest, macos-latest, windows-latest] exclude: # There is a known issue where Python C extensions -- cgit v1.2.3 From 743d08b7311cf973f3930d650f773916fa81eca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81rni=20Dagur?= Date: Tue, 22 Sep 2020 05:23:40 +0000 Subject: CI: Only build documentation on push --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c60acd2..5c0bf52 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -150,7 +150,7 @@ jobs: docs-publish: runs-on: ubuntu-latest - if: github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/master' && github.event.action == 'push' steps: - uses: actions/checkout@v2 with: -- cgit v1.2.3 From d3953185e8196a2dc6bfb55c979f195fe6969519 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81rni=20Dagur?= Date: Tue, 22 Sep 2020 05:25:31 +0000 Subject: Update to PyO3 0.12 --- Cargo.toml | 2 +- src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 38ae843..0a76e0a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ debug = true [dependencies] adblock = { version = "0.3.2", default-features = false, features = ["full-regex-handling", "embedded-domain-resolver"] } -pyo3 = "0.11" +pyo3 = "0.12" [lib] name = "adblock" diff --git a/src/lib.rs b/src/lib.rs index 7839a42..fc837b8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,7 +17,7 @@ use adblock::engine::Engine as RustEngine; use adblock::lists::FilterFormat; use adblock::lists::FilterSet as RustFilterSet; use pyo3::class::PyObjectProtocol; -use pyo3::exceptions::ValueError as PyValueError; +use pyo3::exceptions::PyValueError; use pyo3::prelude::*; use pyo3::types::PyBytes; use pyo3::PyErr; -- cgit v1.2.3 From afe851835fbe1cf62b6cbfd11e532d5ab72d3fd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81rni=20Dagur?= Date: Tue, 22 Sep 2020 05:28:07 +0000 Subject: Bump version number to 0.3.2 --- Cargo.toml | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0a76e0a..05d1891 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "adblock" publish = false -version = "0.3.1" +version = "0.3.2" authors = ["Árni Dagur "] license = "MIT OR Apache-2.0" -- cgit v1.2.3 From 1f73df47e5a0fd41b912ba21c5897b4c77401db1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81rni=20Dagur?= Date: Tue, 22 Sep 2020 05:33:19 +0000 Subject: CI: Fix the setting up of Python 3.9 --- .github/workflows/ci.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5c0bf52..141fea4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,11 +53,16 @@ jobs: - name: Checkout uses: actions/checkout@v1 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + - uses: actions/setup-python@v2 + if: matrix.python-version != 3.9 with: python-version: ${{ matrix.python-version }} + - uses: actions/setup-python@v2 + if: matrix.python-version == 3.9 + with: + python-version: '3.9.0-alpha - 3.9.0' + - name: Install dependencies run: | python -m pip install --upgrade pip @@ -98,10 +103,16 @@ jobs: steps: - uses: actions/checkout@v1 - - uses: actions/setup-python@v1 + - uses: actions/setup-python@v2 + if: matrix.python-version != 3.9 with: python-version: ${{ matrix.python-version }} + - uses: actions/setup-python@v2 + if: matrix.python-version == 3.9 + with: + python-version: '3.9.0-alpha - 3.9.0' + - name: Install latest nightly uses: actions-rs/toolchain@v1 with: -- cgit v1.2.3