Skip to content

Commit

Permalink
Merge pull request #12 from zytedata/py3.12
Browse files Browse the repository at this point in the history
Add Python 3.12 support, make small CI improvements
  • Loading branch information
wRAR authored Apr 1, 2024
2 parents 414671d + 5ad2a96 commit 1fddc8b
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 35 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 7 additions & 22 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -18,4 +18,4 @@ repos:
- flake8-debugger
- flake8-string-format
repo: https://github.com/pycqa/flake8
rev: 4.0.1
rev: 7.0.0
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
)
Empty file added tests/__init__.py
Empty file.
3 changes: 2 additions & 1 deletion tests/test_matcher.py
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
3 changes: 2 additions & 1 deletion tests/test_patterns.py
Original file line number Diff line number Diff line change
@@ -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")

Expand Down
23 changes: 19 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = min,py38,py39,py310,py311,mypy,docs
envlist = min,py38,py39,py310,py311,py312,mypy,docs

[testenv]
deps =
Expand All @@ -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
Expand All @@ -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/*
3 changes: 2 additions & 1 deletion url_matcher/example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Example of usage of the URLMatcher library
"""

import dataclasses
import random
import time
Expand Down Expand Up @@ -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!")
1 change: 1 addition & 0 deletions url_matcher/matcher.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 1fddc8b

Please sign in to comment.