Skip to content

Commit

Permalink
Add pre-commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
wRAR committed Nov 4, 2024
1 parent ad6436c commit 68a40a3
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
fail-fast: false
matrix:
python-version: ["3.13"]
tox-job: ["twine-check"]
tox-job: ["linters", "twine-check"]

steps:
- uses: actions/checkout@v4
Expand Down
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
repos:
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 7.1.1
hooks:
- id: flake8
additional_dependencies:
- flake8-docstrings
- flake8-print
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.19.1
hooks:
- id: blacken-docs
additional_dependencies:
- black==24.10.0
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ Source = "https://github.com/zytedata/duplicate-url-discarder-rules"

[tool.setuptools.package-data]
'duplicate_url_discarder_rules' = ['**/*.json']

[tool.black]
target-version = ["py39", "py310", "py311", "py312", "py313"]

[tool.isort]
profile = "black"
multi_line_output = 3
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
ignore = E203, E266, E501, W503, C901
max-line-length = 88
select = B,C,E,F,W,T4
2 changes: 1 addition & 1 deletion tests/normalizer/test_normalizer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from duplicate_url_discarder.url_canonicalizer import UrlCanonicalizer
from duplicate_url_discarder.processors import NormalizerProcessor
from duplicate_url_discarder.url_canonicalizer import UrlCanonicalizer

from duplicate_url_discarder_rules import RULE_PATHS

Expand Down
2 changes: 1 addition & 1 deletion tests/queryRemovalExcept/test_query_removal_except.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from duplicate_url_discarder.url_canonicalizer import UrlCanonicalizer
from duplicate_url_discarder.processors import QueryRemovalExceptProcessor
from duplicate_url_discarder.url_canonicalizer import UrlCanonicalizer

from duplicate_url_discarder_rules import RULE_PATHS

Expand Down
2 changes: 1 addition & 1 deletion tests/subpathRemoval/test_subpath_removal.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from duplicate_url_discarder.url_canonicalizer import UrlCanonicalizer
from duplicate_url_discarder.processors import SubpathRemovalProcessor
from duplicate_url_discarder.url_canonicalizer import UrlCanonicalizer

from duplicate_url_discarder_rules import RULE_PATHS

Expand Down
7 changes: 6 additions & 1 deletion tests/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

from url_matcher import Patterns

from duplicate_url_discarder_rules import RULE_PATHS, RULE_PATHS_ARTICLE, RULE_PATHS_PRODUCT, RULE_PATHS_COMMON
from duplicate_url_discarder_rules import (
RULE_PATHS,
RULE_PATHS_ARTICLE,
RULE_PATHS_COMMON,
RULE_PATHS_PRODUCT,
)


def test_rule_validity():
Expand Down
6 changes: 5 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py39,py310,py311,py312,py313,twine-check
envlist = py39,py310,py311,py312,py313,linters,twine-check

[testenv]
deps =
Expand All @@ -11,6 +11,10 @@ commands =
py.test \
{posargs:duplicate_url_discarder_rules tests}

[testenv:linters]
deps = pre-commit
commands = pre-commit run --all-files --show-diff-on-failure

[testenv:twine-check]
deps =
build
Expand Down

0 comments on commit 68a40a3

Please sign in to comment.