Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ include LICENSE
include Makefile
include README.rst
include requirements-dev.txt
include requirements-flake8.txt
include SECURITY.md
include tox.ini

Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ test: ## Run tests
docs: ## Build docs
tox -e py310-docs

.PHONY: format
format: ## Format Python files
tox exec -e py310-lint -- ruff format --target-version=py310 --exclude=_vendor setup.py bleach/ tests/ tests_website/

.PHONY: lint
lint: ## Lint files
tox exec -e py310-format-check -- black --target-version=py310 --exclude=_vendor setup.py bleach/ tests/ tests_website/
tox -e py310-lint
tox -e py310-format-check

.PHONY: vendorverify
vendorverify: ## Verify vendored files
Expand Down
8 changes: 2 additions & 6 deletions bleach/linkifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ def build_url_re(tlds=TLDS, protocols=html5lib_shim.allowed_protocols):
(?:[/?][^\s\{{\}}\|\\\^`<>"]*)?
# /path/zz (excluding "unsafe" chars from RFC 3986,
# except for # and ~, which happen in practice)
""".format(
"|".join(sorted(protocols)), "|".join(sorted(tlds))
),
""".format("|".join(sorted(protocols)), "|".join(sorted(tlds))),
re.IGNORECASE | re.VERBOSE | re.UNICODE,
)

Expand Down Expand Up @@ -81,9 +79,7 @@ def build_email_re(tlds=TLDS):
|^"([\001-\010\013\014\016-\037!#-\[\]-\177]
|\\[\001-\011\013\014\016-\177])*" # quoted-string
)@(?:[A-Z0-9](?:[A-Z0-9-]{{0,61}}[A-Z0-9])?\.)+(?:{0})) # domain
""".format(
"|".join(tlds)
),
""".format("|".join(tlds)),
re.IGNORECASE | re.MULTILINE | re.VERBOSE,
)

Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
-e .

black==24.4.2; implementation_name == 'cpython'
build==1.2.1
mypy==1.10.1; implementation_name =='cpython'
pytest==8.2.2
ruff==0.15.6; implementation_name == 'cpython'
setuptools==80.7.1
tox==4.16.0
tox-gh-actions==3.2.0
Expand Down
2 changes: 0 additions & 2 deletions requirements-flake8.txt

This file was deleted.

16 changes: 0 additions & 16 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
[flake8]
exclude =
.git/,
.tox/,
bleach/_vendor/*
ignore =
# E203: whitespace before ":"; doesn't work with black
E203,
# E501: line too long
E501,
# E731: do not assign a lambda expression, use a def
E731,
# W503: line break before opertor; this doesn't work with black
W503
max-line-length = 88

[tool:pytest]
filterwarnings =
error
Expand Down
7 changes: 5 additions & 2 deletions tests/test_clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,14 @@ def test_poster_attribute():

def test_attributes_callable():
"""Verify attributes can take a callable"""
ATTRS = lambda tag, name, val: name == "title"

def attrs_fun(tag, name, val):
return name == "title"

TAGS = {"a"}

text = '<a href="/foo" title="blah">example</a>'
assert clean(text, tags=TAGS, attributes=ATTRS) == '<a title="blah">example</a>'
assert clean(text, tags=TAGS, attributes=attrs_fun) == '<a title="blah">example</a>'


def test_attributes_wildcard():
Expand Down
12 changes: 2 additions & 10 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ envlist =
py{310,311,312,313,314,py3}-tinycss2
py{310,311,312,313,314}-build-no-lang
py310-docs
py310-format-check
py310-lint
py310-vendorverify

Expand Down Expand Up @@ -93,10 +92,10 @@ commands =

[testenv:py310-lint]
changedir = {toxinidir}
deps = -rrequirements-flake8.txt
platform = linux
commands =
flake8 setup.py tests/ bleach/ tests_website/
ruff format --check --target-version=py310 --exclude=_vendor setup.py bleach/ tests/ tests_website/
ruff check --target-version=py310 --exclude=_vendor setup.py bleach/ tests/ tests_website/

[testenv:py310-vendorverify]
allowlist_externals = {toxinidir}/scripts/vendor_verify.sh
Expand All @@ -106,13 +105,6 @@ platform = linux
commands =
{toxinidir}/scripts/vendor_verify.sh

[testenv:py310-format-check]
changedir = {toxinidir}
deps = -rrequirements-dev.txt
platform = linux
commands =
black --target-version=py310 --check --diff --exclude=_vendor setup.py bleach/ tests/ tests_website/

[testenv:py310-docs]
changedir = docs
deps = -rrequirements-dev.txt
Expand Down
Loading