attrs icon indicating copy to clipboard operation
attrs copied to clipboard

No mention of how to use eq/order in narrative docs

Open wsanchez opened this issue 6 years ago • 5 comments

I'm getting a new handy error from mypy:

src/ims/application/_main.py:74:2: error: cmp is deprecated, use eq and order  [misc]

In order to make sure I'm using those correctly, I went to attrs.org and looked for some documentation on these new options, but I see no mention of either of the eq or order options, except for some mentions of eq in the section on hashing.

With a deprecation notice like this, a link to some documentation for how to fix your code would be very helpful.

wsanchez avatar Nov 12 '19 18:11 wsanchez

Changing cmp=False to eq=False gives me a more glorious error:

src/ims/application/_main.py:74:2: error: No overload variant of "attrs" matches argument types "bool", "bool", "bool", "bool"  [call-overload]
    @attrs(frozen=True, auto_attribs=True, kw_only=True, eq=False)
     ^
src/ims/application/_main.py:74:2: note: Possible overload variants:
src/ims/application/_main.py:74:2: note:     def [_C <: type] attrs(maybe_cls: _C, these: Optional[Dict[str, Any]] = ..., repr_ns: Optional[str] = ..., repr: bool = ..., cmp: bool = ..., hash: Optional[bool] = ..., init: bool = ..., slots: bool = ..., frozen: bool = ..., weakref_slot: bool = ..., str: bool = ..., auto_attribs: bool = ..., kw_only: bool = ..., cache_hash: bool = ..., auto_exc: bool = ...) -> _C
src/ims/application/_main.py:74:2: note:     def attrs(maybe_cls: None = ..., these: Optional[Dict[str, Any]] = ..., repr_ns: Optional[str] = ..., repr: bool = ..., cmp: bool = ..., hash: Optional[bool] = ..., init: bool = ..., slots: bool = ..., frozen: bool = ..., weakref_slot: bool = ..., str: bool = ..., auto_attribs: bool = ..., kw_only: bool = ..., cache_hash: bool = ..., auto_exc: bool = ...) -> Callable[[_C], _C]
Found 14 errors in 12 files (checked 1 source file)

wsanchez avatar Nov 12 '19 19:11 wsanchez

Hi. There are 2 issues here.

  1. That error shouldn't have been there. It's just deprecated not an error. This has been fixed on mypy master.
  2. The attrs stubs that are shipped with mypy are old. You should install attrs into the environment from which you run mypy.

I don't know what to do about 2. We could update the stubs or we could delete them. Anybody have opinions?

euresti avatar Nov 12 '19 19:11 euresti

By stubs you mean stubs in typeshed? Is that for us to decide?

hynek avatar Nov 12 '19 19:11 hynek

@euresti For #2, should it be enough to simply install attrs? In Tox, I turned off skip_install so that dependencies are installed:

wsanchez$ ./.tox/mypy/bin/pip freeze | grep '^attrs'
attrs==19.1.0

…but I still get the same errors. And it's fixed if I update to attrs==19.3.0.

Leaving this comment here for the next developer's benefit.

wsanchez avatar Nov 12 '19 19:11 wsanchez

I think it's for us to decide. We decided to give me permission to add the stubs to attrs. :)

eq and order are new in 19.3(?) so it makes sense that it would fail unless you add them.

euresti avatar Nov 12 '19 19:11 euresti