diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 240ffca..35aca3e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -13,11 +13,11 @@ 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.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..e46436e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,11 +23,12 @@ jobs: - python-version: '3.9' - python-version: '3.10' - python-version: '3.11' + - 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 @@ -46,12 +47,12 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.10'] - tox-job: ["mypy", "docs"] + python-version: ['3.12'] + 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 @@ -61,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/.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/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/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 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 62e8ac1..b3d0cfd 100644 --- a/tests/test_patterns.py +++ b/tests/test_patterns.py @@ -1,8 +1,9 @@ import pytest -from 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") diff --git a/tox.ini b/tox.ini index 6369bce..8105e8a 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 = @@ -20,9 +20,9 @@ deps = [testenv:mypy] deps = - mypy==0.910 - -commands = mypy --ignore-missing-imports --no-warn-no-return url_matcher tests + mypy==1.9.0 +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/* 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