Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump attrs requirement from >=17.4.0 to >=19.2.0 #7802

Merged
merged 1 commit into from
Sep 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions changelog/7802.trivial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The ``attrs`` dependency requirement is now >=19.2.0 instead of >=17.4.0.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 10 additions & 11 deletions src/_pytest/_code/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
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
Expand Down Expand Up @@ -918,7 +917,7 @@ def repr_excinfo(
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
Expand All @@ -936,7 +935,7 @@ def toterminal(self, tw: TerminalWriter) -> None:


# 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]
Expand All @@ -954,7 +953,7 @@ def toterminal(self, tw: TerminalWriter) -> None:
tw.line(content)


@attr.s(**{ATTRS_EQ_FIELD: False}) # type: ignore
@attr.s(eq=False)
class ExceptionChainRepr(ExceptionRepr):
chain = attr.ib(
type=Sequence[
Expand All @@ -978,7 +977,7 @@ def toterminal(self, tw: TerminalWriter) -> None:
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")
Expand All @@ -988,7 +987,7 @@ def toterminal(self, tw: TerminalWriter) -> None:
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])
Expand Down Expand Up @@ -1022,7 +1021,7 @@ def __init__(self, tblines: Sequence[str]) -> None:
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
Expand All @@ -1031,7 +1030,7 @@ def toterminal(self, tw: TerminalWriter) -> None:
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"])
Expand Down Expand Up @@ -1111,7 +1110,7 @@ def __str__(self) -> str:
)


@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)
Expand All @@ -1128,7 +1127,7 @@ def toterminal(self, tw: TerminalWriter) -> None:
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])

Expand All @@ -1137,7 +1136,7 @@ def toterminal(self, tw: TerminalWriter, indent="") -> None:
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]])

Expand Down
5 changes: 1 addition & 4 deletions src/_pytest/assertion/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
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
Expand Down Expand Up @@ -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 = []
Expand Down
6 changes: 0 additions & 6 deletions src/_pytest/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,6 @@ def final(f): # noqa: F811
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:
Expand Down
3 changes: 1 addition & 2 deletions testing/test_assertion.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
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):
Expand Down Expand Up @@ -945,7 +944,7 @@ def test_attrs_with_attribute_comparison_off(self):
@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")
Expand Down
2 changes: 0 additions & 2 deletions testing/test_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 1 addition & 5 deletions testing/test_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,11 +532,7 @@ def f(_):
# 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",
Expand Down
2 changes: 0 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down