Deprecate zope-interface support (#1120)

This commit is contained in:
Hynek Schlawack 2023-04-10 15:34:38 +02:00 committed by GitHub
parent d1aaeeed78
commit c8b342d34f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 3 deletions

View File

@ -0,0 +1,5 @@
The support for *zope-interface* via the `attrs.validators.provides` validator is now deprecated and will be removed in, or after, April 2024.
The presence of a C-based package in our developement dependencies has caused headaches and we're not under the impression it's used a lot.
Let us know if you're using it and we might publish it as a separate package.

View File

@ -244,7 +244,17 @@ def provides(interface):
:raises TypeError: With a human readable error message, the attribute :raises TypeError: With a human readable error message, the attribute
(of type `attrs.Attribute`), the expected interface, and the (of type `attrs.Attribute`), the expected interface, and the
value it got. value it got.
.. deprecated:: 23.1.0
""" """
import warnings
warnings.warn(
"attrs's zope-interface support is deprecated and will be removed in, "
"or after, April 2024.",
DeprecationWarning,
stacklevel=2,
)
return _ProvidesValidator(interface) return _ProvidesValidator(interface)

View File

@ -349,7 +349,9 @@ class TestProvides:
def f(self): def f(self):
pass pass
with pytest.deprecated_call():
v = provides(ifoo) v = provides(ifoo)
v(None, simple_attr("x"), C()) v(None, simple_attr("x"), C())
def test_fail(self, ifoo): def test_fail(self, ifoo):
@ -359,9 +361,12 @@ class TestProvides:
value = object() value = object()
a = simple_attr("x") a = simple_attr("x")
with pytest.deprecated_call():
v = provides(ifoo) v = provides(ifoo)
with pytest.raises(TypeError) as e: with pytest.raises(TypeError) as e:
v(None, a, value) v(None, a, value)
assert ( assert (
"'x' must provide {interface!r} which {value!r} doesn't.".format( "'x' must provide {interface!r} which {value!r} doesn't.".format(
interface=ifoo, value=value interface=ifoo, value=value
@ -375,7 +380,9 @@ class TestProvides:
""" """
Returned validator has a useful `__repr__`. Returned validator has a useful `__repr__`.
""" """
with pytest.deprecated_call():
v = provides(ifoo) v = provides(ifoo)
assert ( assert (
"<provides validator for interface {interface!r}>".format( "<provides validator for interface {interface!r}>".format(
interface=ifoo interface=ifoo