Skip to content

Commit cd67c2a

Browse files
authored
Merge pull request #7802 from bluetech/bump-attrs
Bump attrs requirement from >=17.4.0 to >=19.2.0
2 parents 91fa11b + 32bb8f3 commit cd67c2a

File tree

10 files changed

+16
-34
lines changed

10 files changed

+16
-34
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
- name: "ubuntu-py37"
8080
python: "3.7"
8181
os: ubuntu-latest
82-
tox_env: "py37-lsof-numpy-oldattrs-pexpect"
82+
tox_env: "py37-lsof-numpy-pexpect"
8383
use_coverage: true
8484
- name: "ubuntu-py37-pluggy"
8585
python: "3.7"

changelog/7802.trivial.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The ``attrs`` dependency requirement is now >=19.2.0 instead of >=17.4.0.

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ packages =
4040
_pytest.mark
4141
pytest
4242
install_requires =
43-
attrs>=17.4.0
43+
attrs>=19.2.0
4444
iniconfig
4545
packaging
4646
pluggy>=0.12,<1.0

src/_pytest/_code/code.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
from _pytest._io import TerminalWriter
3838
from _pytest._io.saferepr import safeformat
3939
from _pytest._io.saferepr import saferepr
40-
from _pytest.compat import ATTRS_EQ_FIELD
4140
from _pytest.compat import final
4241
from _pytest.compat import get_real_func
4342
from _pytest.compat import overload
@@ -918,7 +917,7 @@ def repr_excinfo(
918917
return ExceptionChainRepr(repr_chain)
919918

920919

921-
@attr.s(**{ATTRS_EQ_FIELD: False}) # type: ignore
920+
@attr.s(eq=False)
922921
class TerminalRepr:
923922
def __str__(self) -> str:
924923
# FYI this is called from pytest-xdist's serialization of exception
@@ -936,7 +935,7 @@ def toterminal(self, tw: TerminalWriter) -> None:
936935

937936

938937
# This class is abstract -- only subclasses are instantiated.
939-
@attr.s(**{ATTRS_EQ_FIELD: False}) # type: ignore
938+
@attr.s(eq=False)
940939
class ExceptionRepr(TerminalRepr):
941940
# Provided by subclasses.
942941
reprcrash = None # type: Optional[ReprFileLocation]
@@ -954,7 +953,7 @@ def toterminal(self, tw: TerminalWriter) -> None:
954953
tw.line(content)
955954

956955

957-
@attr.s(**{ATTRS_EQ_FIELD: False}) # type: ignore
956+
@attr.s(eq=False)
958957
class ExceptionChainRepr(ExceptionRepr):
959958
chain = attr.ib(
960959
type=Sequence[
@@ -978,7 +977,7 @@ def toterminal(self, tw: TerminalWriter) -> None:
978977
super().toterminal(tw)
979978

980979

981-
@attr.s(**{ATTRS_EQ_FIELD: False}) # type: ignore
980+
@attr.s(eq=False)
982981
class ReprExceptionInfo(ExceptionRepr):
983982
reprtraceback = attr.ib(type="ReprTraceback")
984983
reprcrash = attr.ib(type="ReprFileLocation")
@@ -988,7 +987,7 @@ def toterminal(self, tw: TerminalWriter) -> None:
988987
super().toterminal(tw)
989988

990989

991-
@attr.s(**{ATTRS_EQ_FIELD: False}) # type: ignore
990+
@attr.s(eq=False)
992991
class ReprTraceback(TerminalRepr):
993992
reprentries = attr.ib(type=Sequence[Union["ReprEntry", "ReprEntryNative"]])
994993
extraline = attr.ib(type=Optional[str])
@@ -1022,7 +1021,7 @@ def __init__(self, tblines: Sequence[str]) -> None:
10221021
self.extraline = None
10231022

10241023

1025-
@attr.s(**{ATTRS_EQ_FIELD: False}) # type: ignore
1024+
@attr.s(eq=False)
10261025
class ReprEntryNative(TerminalRepr):
10271026
lines = attr.ib(type=Sequence[str])
10281027
style = "native" # type: _TracebackStyle
@@ -1031,7 +1030,7 @@ def toterminal(self, tw: TerminalWriter) -> None:
10311030
tw.write("".join(self.lines))
10321031

10331032

1034-
@attr.s(**{ATTRS_EQ_FIELD: False}) # type: ignore
1033+
@attr.s(eq=False)
10351034
class ReprEntry(TerminalRepr):
10361035
lines = attr.ib(type=Sequence[str])
10371036
reprfuncargs = attr.ib(type=Optional["ReprFuncArgs"])
@@ -1111,7 +1110,7 @@ def __str__(self) -> str:
11111110
)
11121111

11131112

1114-
@attr.s(**{ATTRS_EQ_FIELD: False}) # type: ignore
1113+
@attr.s(eq=False)
11151114
class ReprFileLocation(TerminalRepr):
11161115
path = attr.ib(type=str, converter=str)
11171116
lineno = attr.ib(type=int)
@@ -1128,7 +1127,7 @@ def toterminal(self, tw: TerminalWriter) -> None:
11281127
tw.line(":{}: {}".format(self.lineno, msg))
11291128

11301129

1131-
@attr.s(**{ATTRS_EQ_FIELD: False}) # type: ignore
1130+
@attr.s(eq=False)
11321131
class ReprLocals(TerminalRepr):
11331132
lines = attr.ib(type=Sequence[str])
11341133

@@ -1137,7 +1136,7 @@ def toterminal(self, tw: TerminalWriter, indent="") -> None:
11371136
tw.line(indent + line)
11381137

11391138

1140-
@attr.s(**{ATTRS_EQ_FIELD: False}) # type: ignore
1139+
@attr.s(eq=False)
11411140
class ReprFuncArgs(TerminalRepr):
11421141
args = attr.ib(type=Sequence[Tuple[str, object]])
11431142

src/_pytest/assertion/util.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from _pytest._io.saferepr import _pformat_dispatch
1717
from _pytest._io.saferepr import safeformat
1818
from _pytest._io.saferepr import saferepr
19-
from _pytest.compat import ATTRS_EQ_FIELD
2019

2120
# The _reprcompare attribute on the util module is used by the new assertion
2221
# interpretation code and assertion rewriter to detect this plugin was
@@ -420,9 +419,7 @@ def _compare_eq_cls(
420419
fields_to_check = [field for field, info in all_fields.items() if info.compare]
421420
elif isattrs(left):
422421
all_fields = left.__attrs_attrs__
423-
fields_to_check = [
424-
field.name for field in all_fields if getattr(field, ATTRS_EQ_FIELD)
425-
]
422+
fields_to_check = [field.name for field in all_fields if getattr(field, "eq")]
426423

427424
indent = " "
428425
same = []

src/_pytest/compat.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -371,12 +371,6 @@ def final(f): # noqa: F811
371371
return f
372372

373373

374-
if getattr(attr, "__version_info__", ()) >= (19, 2):
375-
ATTRS_EQ_FIELD = "eq"
376-
else:
377-
ATTRS_EQ_FIELD = "cmp"
378-
379-
380374
if sys.version_info >= (3, 8):
381375
from functools import cached_property as cached_property
382376
else:

testing/test_assertion.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from _pytest import outcomes
1313
from _pytest.assertion import truncate
1414
from _pytest.assertion import util
15-
from _pytest.compat import ATTRS_EQ_FIELD
1615

1716

1817
def mock_config(verbose=0):
@@ -945,7 +944,7 @@ def test_attrs_with_attribute_comparison_off(self):
945944
@attr.s
946945
class SimpleDataObject:
947946
field_a = attr.ib()
948-
field_b = attr.ib(**{ATTRS_EQ_FIELD: False}) # type: ignore
947+
field_b = attr.ib(eq=False)
949948

950949
left = SimpleDataObject(1, "b")
951950
right = SimpleDataObject(1, "b")

testing/test_meta.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ def test_no_warnings(module: str) -> None:
2727
subprocess.check_call((
2828
sys.executable,
2929
"-W", "error",
30-
# https://github.com/pytest-dev/pytest/issues/5901
31-
"-W", "ignore:The usage of `cmp` is deprecated and will be removed on or after 2021-06-01. Please use `eq` and `order` instead.:DeprecationWarning", # noqa: E501
3230
"-c", "__import__({!r})".format(module),
3331
))
3432
# fmt: on

testing/test_unittest.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -532,11 +532,7 @@ def f(_):
532532
# will crash both at test time and at teardown
533533
"""
534534
)
535-
# Ignore DeprecationWarning (for `cmp`) from attrs through twisted,
536-
# for stable test results.
537-
result = testdir.runpytest(
538-
"-vv", "-oconsole_output_style=classic", "-W", "ignore::DeprecationWarning"
539-
)
535+
result = testdir.runpytest("-vv", "-oconsole_output_style=classic")
540536
result.stdout.fnmatch_lines(
541537
[
542538
"test_trial_error.py::TC::test_four FAILED",

tox.ini

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ setenv =
4545
extras = testing
4646
deps =
4747
doctesting: PyYAML
48-
oldattrs: attrs==17.4.0
49-
oldattrs: hypothesis<=4.38.1
5048
numpy: numpy
5149
pexpect: pexpect
5250
pluggymaster: git+https://github.com/pytest-dev/pluggy.git@master

0 commit comments

Comments
 (0)