Skip to content

Commit c8b342d

Browse files
authored
Deprecate zope-interface support (#1120)
1 parent d1aaeee commit c8b342d

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

changelog.d/1120.deprecation.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
The support for *zope-interface* via the `attrs.validators.provides` validator is now deprecated and will be removed in, or after, April 2024.
2+
3+
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.
4+
5+
Let us know if you're using it and we might publish it as a separate package.

src/attr/validators.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,17 @@ def provides(interface):
244244
:raises TypeError: With a human readable error message, the attribute
245245
(of type `attrs.Attribute`), the expected interface, and the
246246
value it got.
247+
248+
.. deprecated:: 23.1.0
247249
"""
250+
import warnings
251+
252+
warnings.warn(
253+
"attrs's zope-interface support is deprecated and will be removed in, "
254+
"or after, April 2024.",
255+
DeprecationWarning,
256+
stacklevel=2,
257+
)
248258
return _ProvidesValidator(interface)
249259

250260

tests/test_validators.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,9 @@ class C:
349349
def f(self):
350350
pass
351351

352-
v = provides(ifoo)
352+
with pytest.deprecated_call():
353+
v = provides(ifoo)
354+
353355
v(None, simple_attr("x"), C())
354356

355357
def test_fail(self, ifoo):
@@ -359,9 +361,12 @@ def test_fail(self, ifoo):
359361
value = object()
360362
a = simple_attr("x")
361363

362-
v = provides(ifoo)
364+
with pytest.deprecated_call():
365+
v = provides(ifoo)
366+
363367
with pytest.raises(TypeError) as e:
364368
v(None, a, value)
369+
365370
assert (
366371
"'x' must provide {interface!r} which {value!r} doesn't.".format(
367372
interface=ifoo, value=value
@@ -375,7 +380,9 @@ def test_repr(self, ifoo):
375380
"""
376381
Returned validator has a useful `__repr__`.
377382
"""
378-
v = provides(ifoo)
383+
with pytest.deprecated_call():
384+
v = provides(ifoo)
385+
379386
assert (
380387
"<provides validator for interface {interface!r}>".format(
381388
interface=ifoo

0 commit comments

Comments
 (0)