Skip to content

Commit

Permalink
Deprecate zope-interface support
Browse files Browse the repository at this point in the history
It's a C-based dependency for a dozen of lines of code.

If there's interest, we can publish it as a separate package.
  • Loading branch information
hynek committed Apr 5, 2023
1 parent 5a7d978 commit 915674b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/attr/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,17 @@ def provides(interface):
:raises TypeError: With a human readable error message, the attribute
(of type `attrs.Attribute`), the expected interface, and the
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)


Expand Down
13 changes: 10 additions & 3 deletions tests/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,9 @@ class C:
def f(self):
pass

v = provides(ifoo)
with pytest.deprecated_call():
v = provides(ifoo)

v(None, simple_attr("x"), C())

def test_fail(self, ifoo):
Expand All @@ -359,9 +361,12 @@ def test_fail(self, ifoo):
value = object()
a = simple_attr("x")

v = provides(ifoo)
with pytest.deprecated_call():
v = provides(ifoo)

with pytest.raises(TypeError) as e:
v(None, a, value)

assert (
"'x' must provide {interface!r} which {value!r} doesn't.".format(
interface=ifoo, value=value
Expand All @@ -375,7 +380,9 @@ def test_repr(self, ifoo):
"""
Returned validator has a useful `__repr__`.
"""
v = provides(ifoo)
with pytest.deprecated_call():
v = provides(ifoo)

assert (
"<provides validator for interface {interface!r}>".format(
interface=ifoo
Expand Down

0 comments on commit 915674b

Please sign in to comment.