diff --git a/MANIFEST.in b/MANIFEST.in
index 8f0af734..df94c77e 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -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
diff --git a/Makefile b/Makefile
index f66f8019..51c3b265 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/bleach/linkifier.py b/bleach/linkifier.py
index 8fcefb2c..c9513509 100644
--- a/bleach/linkifier.py
+++ b/bleach/linkifier.py
@@ -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,
)
@@ -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,
)
diff --git a/requirements-dev.txt b/requirements-dev.txt
index 0cae69ec..5f4b7a93 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -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
diff --git a/requirements-flake8.txt b/requirements-flake8.txt
deleted file mode 100644
index 806cdff7..00000000
--- a/requirements-flake8.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-# Requirements for running flake8
-flake8==6.0.0
diff --git a/setup.cfg b/setup.cfg
index f631ecc9..43d61f27 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -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
diff --git a/tests/test_clean.py b/tests/test_clean.py
index 86ee129b..5a13cfaf 100644
--- a/tests/test_clean.py
+++ b/tests/test_clean.py
@@ -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 = 'example'
- assert clean(text, tags=TAGS, attributes=ATTRS) == 'example'
+ assert clean(text, tags=TAGS, attributes=attrs_fun) == 'example'
def test_attributes_wildcard():
diff --git a/tox.ini b/tox.ini
index 600d70d9..948bd6b1 100644
--- a/tox.ini
+++ b/tox.ini
@@ -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
@@ -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
@@ -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