From 043177ad7d10c241b28e48cdb617fe40431eb297 Mon Sep 17 00:00:00 2001 From: Andrey Rakhmatullin Date: Mon, 1 Apr 2024 13:20:41 +0500 Subject: [PATCH 1/6] Bump linter versions. --- .pre-commit-config.yaml | 6 +++--- url_matcher/example.py | 3 ++- url_matcher/matcher.py | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6616ca8..1728dce 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,12 +3,12 @@ repos: - id: black language_version: python3 repo: https://github.com/psf/black - rev: 22.3.0 + rev: 24.3.0 - hooks: - id: isort language_version: python3 repo: https://github.com/pycqa/isort - rev: 5.12.0 + rev: 5.13.2 - hooks: - id: flake8 language_version: python3 @@ -18,4 +18,4 @@ repos: - flake8-debugger - flake8-string-format repo: https://github.com/pycqa/flake8 - rev: 4.0.1 + rev: 7.0.0 diff --git a/url_matcher/example.py b/url_matcher/example.py index f930f60..d9bb6f7 100644 --- a/url_matcher/example.py +++ b/url_matcher/example.py @@ -1,6 +1,7 @@ """ Example of usage of the URLMatcher library """ + import dataclasses import random import time @@ -100,6 +101,6 @@ def add_patterns(domain): end = time.perf_counter() # It took in my machine ~ 0.04 millis per URL -print(f"{((end-start)/N_URLS)*1000:.3f} milliseconds per URL. Total {end-start} seconds to match {N_URLS} URLs") +print(f"{((end - start) / N_URLS) * 1000:.3f} milliseconds per URL. Total {end - start} seconds to match {N_URLS} URLs") print("Everything worked fine!") diff --git a/url_matcher/matcher.py b/url_matcher/matcher.py index adf4443..29b0418 100644 --- a/url_matcher/matcher.py +++ b/url_matcher/matcher.py @@ -1,6 +1,7 @@ """ The matcher module contains the UrlMatcher class. """ + from dataclasses import dataclass, field from itertools import chain from typing import Any, Dict, Iterable, List, Mapping, Optional, Tuple, Union From 0a7cfdb318c08c05a2154d8c3751d8000955584d Mon Sep 17 00:00:00 2001 From: Andrey Rakhmatullin Date: Mon, 1 Apr 2024 16:27:27 +0500 Subject: [PATCH 2/6] Add Python 3.12 support. --- .github/workflows/publish.yml | 2 +- .github/workflows/test.yml | 3 ++- setup.py | 1 + tox.ini | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 240ffca..84d62b5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -17,7 +17,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: '3.x' + python-version: '3.12' - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c5bde86..bb0c03d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,6 +23,7 @@ jobs: - python-version: '3.9' - python-version: '3.10' - python-version: '3.11' + - python-version: '3.12' steps: - uses: actions/checkout@v2 @@ -46,7 +47,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.10'] + python-version: ['3.12'] tox-job: ["mypy", "docs"] steps: - uses: actions/checkout@v2 diff --git a/setup.py b/setup.py index 43a38f7..c02c404 100644 --- a/setup.py +++ b/setup.py @@ -42,5 +42,6 @@ def get_version(): "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ], ) diff --git a/tox.ini b/tox.ini index 6369bce..f4876e5 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = min,py38,py39,py310,py311,mypy,docs +envlist = min,py38,py39,py310,py311,py312,mypy,docs [testenv] deps = From 1c27cb9a0fbcba4be98a59923442dba0c9c791ed Mon Sep 17 00:00:00 2001 From: Andrey Rakhmatullin Date: Mon, 1 Apr 2024 16:31:49 +0500 Subject: [PATCH 3/6] CI improvements. --- .github/workflows/publish.yml | 4 ++-- .github/workflows/test.yml | 26 +++++--------------------- tox.ini | 19 +++++++++++++++++-- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 84d62b5..35aca3e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -13,9 +13,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: '3.12' - name: Install dependencies diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bb0c03d..e46436e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,9 +26,9 @@ jobs: - python-version: '3.12' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -48,11 +48,11 @@ jobs: fail-fast: false matrix: python-version: ['3.12'] - tox-job: ["mypy", "docs"] + tox-job: ["mypy", "docs", "pre-commit", "twinecheck"] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -62,19 +62,3 @@ jobs: - name: tox run: | tox -e ${{ matrix.tox-job }} - - pre-commit: - runs-on: ubuntu-latest - strategy: - fail-fast: false - steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install pre-commit - - name: pre-commit linters - run: | - pre-commit install && pre-commit run --all-files diff --git a/tox.ini b/tox.ini index f4876e5..95b38ea 100644 --- a/tox.ini +++ b/tox.ini @@ -21,8 +21,8 @@ deps = [testenv:mypy] deps = mypy==0.910 - -commands = mypy --ignore-missing-imports --no-warn-no-return url_matcher tests +commands = + mypy --ignore-missing-imports --no-warn-no-return url_matcher tests [docs] changedir = docs @@ -35,3 +35,18 @@ changedir = {[docs]changedir} deps = {[docs]deps} commands = sphinx-build -W -b html . {envtmpdir}/html + +[testenv:pre-commit] +deps = + pre-commit +commands = + pre-commit run --all-files --show-diff-on-failure + +[testenv:twinecheck] +basepython = python3 +deps = + twine==5.0.0 + build==1.2.1 +commands = + python -m build --sdist + twine check dist/* From 764cd42e5f9f40546f279e2791521cd9f953288e Mon Sep 17 00:00:00 2001 From: Andrey Rakhmatullin Date: Mon, 1 Apr 2024 16:33:03 +0500 Subject: [PATCH 4/6] Bump mypy. --- tests/__init__.py | 0 tox.ini | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 tests/__init__.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tox.ini b/tox.ini index 95b38ea..8105e8a 100644 --- a/tox.ini +++ b/tox.ini @@ -20,7 +20,7 @@ deps = [testenv:mypy] deps = - mypy==0.910 + mypy==1.9.0 commands = mypy --ignore-missing-imports --no-warn-no-return url_matcher tests From cef5764b3f9451148415261235dafb1b7ca49d8b Mon Sep 17 00:00:00 2001 From: Andrey Rakhmatullin Date: Mon, 1 Apr 2024 16:35:19 +0500 Subject: [PATCH 5/6] Fix tests. --- tests/test_patterns.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_patterns.py b/tests/test_patterns.py index 62e8ac1..dfe3d41 100644 --- a/tests/test_patterns.py +++ b/tests/test_patterns.py @@ -1,6 +1,6 @@ import pytest -from util import load_json_fixture +from tests.util import load_json_fixture from url_matcher.patterns import PatternMatcher PATTERNS_FIXTURE = load_json_fixture("single_patterns") From 5ad2a96174c52182c3e9b13342ea2443d3b1a522 Mon Sep 17 00:00:00 2001 From: Andrey Rakhmatullin Date: Mon, 1 Apr 2024 19:22:59 +0500 Subject: [PATCH 6/6] Change imports to relative ones. --- tests/test_matcher.py | 3 ++- tests/test_patterns.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_matcher.py b/tests/test_matcher.py index 88ea0ea..12ce005 100644 --- a/tests/test_matcher.py +++ b/tests/test_matcher.py @@ -1,9 +1,10 @@ import pytest -from tests.util import load_json_fixture from url_matcher import Patterns, URLMatcher from url_matcher.matcher import IncludePatternsWithoutDomainError +from .util import load_json_fixture + PATTERNS_FIXTURE = load_json_fixture("patterns") CORNER_CASES_FIXTURE = load_json_fixture("patterns_corner_cases") RULES_FIXTURE = load_json_fixture("rules") diff --git a/tests/test_patterns.py b/tests/test_patterns.py index dfe3d41..b3d0cfd 100644 --- a/tests/test_patterns.py +++ b/tests/test_patterns.py @@ -1,8 +1,9 @@ import pytest -from tests.util import load_json_fixture from url_matcher.patterns import PatternMatcher +from .util import load_json_fixture + PATTERNS_FIXTURE = load_json_fixture("single_patterns") CORNER_CASES_FIXTURE = load_json_fixture("single_patterns_corner_cases")