Bump attrs requirement from >=17.4.0 to >=19.2.0

This allows us to remove the `ATTRS_EQ_FIELD` thing which is causing
some annoyance.
This commit is contained in:
Ran Benita 2020-09-23 14:28:10 +03:00
parent 28ba9ab737
commit 32bb8f3a63
10 changed files with 16 additions and 34 deletions

View File

@ -79,7 +79,7 @@ jobs:
- name: "ubuntu-py37"
python: "3.7"
os: ubuntu-latest
tox_env: "py37-lsof-numpy-oldattrs-pexpect"
tox_env: "py37-lsof-numpy-pexpect"
use_coverage: true
- name: "ubuntu-py37-pluggy"
python: "3.7"

View File

@ -0,0 +1 @@
The ``attrs`` dependency requirement is now >=19.2.0 instead of >=17.4.0.

View File

@ -40,7 +40,7 @@ packages =
_pytest.mark
pytest
install_requires =
attrs>=17.4.0
attrs>=19.2.0
iniconfig
packaging
pluggy>=0.12,<1.0

View File

@ -37,7 +37,6 @@ from _pytest._code.source import Source
from _pytest._io import TerminalWriter
from _pytest._io.saferepr import safeformat
from _pytest._io.saferepr import saferepr
from _pytest.compat import ATTRS_EQ_FIELD
from _pytest.compat import final
from _pytest.compat import get_real_func
from _pytest.compat import overload
@ -918,7 +917,7 @@ class FormattedExcinfo:
return ExceptionChainRepr(repr_chain)
@attr.s(**{ATTRS_EQ_FIELD: False}) # type: ignore
@attr.s(eq=False)
class TerminalRepr:
def __str__(self) -> str:
# FYI this is called from pytest-xdist's serialization of exception
@ -936,7 +935,7 @@ class TerminalRepr:
# This class is abstract -- only subclasses are instantiated.
@attr.s(**{ATTRS_EQ_FIELD: False}) # type: ignore
@attr.s(eq=False)
class ExceptionRepr(TerminalRepr):
# Provided by subclasses.
reprcrash = None # type: Optional[ReprFileLocation]
@ -954,7 +953,7 @@ class ExceptionRepr(TerminalRepr):
tw.line(content)
@attr.s(**{ATTRS_EQ_FIELD: False}) # type: ignore
@attr.s(eq=False)
class ExceptionChainRepr(ExceptionRepr):
chain = attr.ib(
type=Sequence[
@ -978,7 +977,7 @@ class ExceptionChainRepr(ExceptionRepr):
super().toterminal(tw)
@attr.s(**{ATTRS_EQ_FIELD: False}) # type: ignore
@attr.s(eq=False)
class ReprExceptionInfo(ExceptionRepr):
reprtraceback = attr.ib(type="ReprTraceback")
reprcrash = attr.ib(type="ReprFileLocation")
@ -988,7 +987,7 @@ class ReprExceptionInfo(ExceptionRepr):
super().toterminal(tw)
@attr.s(**{ATTRS_EQ_FIELD: False}) # type: ignore
@attr.s(eq=False)
class ReprTraceback(TerminalRepr):
reprentries = attr.ib(type=Sequence[Union["ReprEntry", "ReprEntryNative"]])
extraline = attr.ib(type=Optional[str])
@ -1022,7 +1021,7 @@ class ReprTracebackNative(ReprTraceback):
self.extraline = None
@attr.s(**{ATTRS_EQ_FIELD: False}) # type: ignore
@attr.s(eq=False)
class ReprEntryNative(TerminalRepr):
lines = attr.ib(type=Sequence[str])
style = "native" # type: _TracebackStyle
@ -1031,7 +1030,7 @@ class ReprEntryNative(TerminalRepr):
tw.write("".join(self.lines))
@attr.s(**{ATTRS_EQ_FIELD: False}) # type: ignore
@attr.s(eq=False)
class ReprEntry(TerminalRepr):
lines = attr.ib(type=Sequence[str])
reprfuncargs = attr.ib(type=Optional["ReprFuncArgs"])
@ -1111,7 +1110,7 @@ class ReprEntry(TerminalRepr):
)
@attr.s(**{ATTRS_EQ_FIELD: False}) # type: ignore
@attr.s(eq=False)
class ReprFileLocation(TerminalRepr):
path = attr.ib(type=str, converter=str)
lineno = attr.ib(type=int)
@ -1128,7 +1127,7 @@ class ReprFileLocation(TerminalRepr):
tw.line(":{}: {}".format(self.lineno, msg))
@attr.s(**{ATTRS_EQ_FIELD: False}) # type: ignore
@attr.s(eq=False)
class ReprLocals(TerminalRepr):
lines = attr.ib(type=Sequence[str])
@ -1137,7 +1136,7 @@ class ReprLocals(TerminalRepr):
tw.line(indent + line)
@attr.s(**{ATTRS_EQ_FIELD: False}) # type: ignore
@attr.s(eq=False)
class ReprFuncArgs(TerminalRepr):
args = attr.ib(type=Sequence[Tuple[str, object]])

View File

@ -16,7 +16,6 @@ from _pytest import outcomes
from _pytest._io.saferepr import _pformat_dispatch
from _pytest._io.saferepr import safeformat
from _pytest._io.saferepr import saferepr
from _pytest.compat import ATTRS_EQ_FIELD
# The _reprcompare attribute on the util module is used by the new assertion
# interpretation code and assertion rewriter to detect this plugin was
@ -420,9 +419,7 @@ def _compare_eq_cls(
fields_to_check = [field for field, info in all_fields.items() if info.compare]
elif isattrs(left):
all_fields = left.__attrs_attrs__
fields_to_check = [
field.name for field in all_fields if getattr(field, ATTRS_EQ_FIELD)
]
fields_to_check = [field.name for field in all_fields if getattr(field, "eq")]
indent = " "
same = []

View File

@ -371,12 +371,6 @@ else:
return f
if getattr(attr, "__version_info__", ()) >= (19, 2):
ATTRS_EQ_FIELD = "eq"
else:
ATTRS_EQ_FIELD = "cmp"
if sys.version_info >= (3, 8):
from functools import cached_property as cached_property
else:

View File

@ -12,7 +12,6 @@ import pytest
from _pytest import outcomes
from _pytest.assertion import truncate
from _pytest.assertion import util
from _pytest.compat import ATTRS_EQ_FIELD
def mock_config(verbose=0):
@ -945,7 +944,7 @@ class TestAssert_reprcompare_attrsclass:
@attr.s
class SimpleDataObject:
field_a = attr.ib()
field_b = attr.ib(**{ATTRS_EQ_FIELD: False}) # type: ignore
field_b = attr.ib(eq=False)
left = SimpleDataObject(1, "b")
right = SimpleDataObject(1, "b")

View File

@ -27,8 +27,6 @@ def test_no_warnings(module: str) -> None:
subprocess.check_call((
sys.executable,
"-W", "error",
# https://github.com/pytest-dev/pytest/issues/5901
"-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
"-c", "__import__({!r})".format(module),
))
# fmt: on

View File

@ -532,11 +532,7 @@ class TestTrialUnittest:
# will crash both at test time and at teardown
"""
)
# Ignore DeprecationWarning (for `cmp`) from attrs through twisted,
# for stable test results.
result = testdir.runpytest(
"-vv", "-oconsole_output_style=classic", "-W", "ignore::DeprecationWarning"
)
result = testdir.runpytest("-vv", "-oconsole_output_style=classic")
result.stdout.fnmatch_lines(
[
"test_trial_error.py::TC::test_four FAILED",

View File

@ -45,8 +45,6 @@ setenv =
extras = testing
deps =
doctesting: PyYAML
oldattrs: attrs==17.4.0
oldattrs: hypothesis<=4.38.1
numpy: numpy
pexpect: pexpect
pluggymaster: git+https://github.com/pytest-dev/pluggy.git@master