Commit Graph

12 Commits

Author SHA1 Message Date
wouter bolsterlee e18b5f340a
Remove various obsolete _compat helpers (#941)
* remove obsolete _compat.iteritems()

* remove obsolete _compat.TYPE

* remove obsolete _compat.isclass()

* remove obsolete _compat.new_class()

* remove obsolete _compat.metadata_proxy
2022-03-21 14:03:22 +01:00
Hynek Schlawack c422bf8041
Drop the deprecated Attribute.cmp (#939)
* Drop the deprecated Attribute.cmp

This has nothing to do with the cmp argument to attr.s/define which have been
undeprecated.

* Add newsfragment

* Add test for attr.ib(cmp=)
2022-03-21 10:29:58 +01:00
Hynek Schlawack 980c8b04f5
Drop Python 2.7 (#936)
* Drop Python 2.7

The tooling situation around Python 2 has deteriorate to such a degree that
upholding compatibility is not tenable anymore for a volunteer-run project.

Signed-off-by: Hynek Schlawack <hs@ox.cx>

* Add newsfragment

* Run Python 3.5 under coverage to make up for Python 2.7

* Wait for py35 in parallel

* Remove fullmatch kludge

* Remove Python 2-specific code

* Revert empty slot test

Also disable pyupgrade on that file.

Signed-off-by: Hynek Schlawack <hs@ox.cx>

* We DO run under 3.5

* Remove __qualname__ workarounds

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update changelog.d/936.breaking.rst

Co-authored-by: Tin Tvrtković <tinchester@gmail.com>

* Compare methods using is

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Tin Tvrtković <tinchester@gmail.com>
2022-03-21 08:47:47 +01:00
davfsa 3df7bbe089
Speedup uses of `object.__setattr__` (#898)
* Speedup uses of `object.__setattr__`

* Add changelog fragment
2022-01-03 13:39:41 +00:00
Hynek Schlawack 046beaaaaa Apply SPDX IDs 2021-12-27 09:29:09 +01:00
Hynek Schlawack 679e4b443d
NG: convert on setattr by default (#886)
* NG: convert on setattr by default

Not doing that from the get-go was an oversight.

Fixes #835

* Add optimization for default on_setattr w/ no work to do

Otherwise we'd end up with an explicit setattr every time.

* Fix optimization for NG default & j/ convert

* NG is actually 3.6+

* Add test for convert optimization for good measure
2021-12-14 15:50:37 +01:00
Hynek Schlawack 20c2d4fc0c
Optimize the case of on_setattr=validate & no validators (#817)
* Optimize the case of on_setattr=validate & no validators

This is important because define/mutable have on_setattr=setters.validate on
default.

Fixes #816

Signed-off-by: Hynek Schlawack <hs@ox.cx>

* Grammar
2021-05-17 09:24:46 +02:00
Antonio Botelho f580185cc4
Undeprecate cmp (#773)
* Document comparison

* Grammar

* Stress independence of eq/order

* Add example for eq

* Be consistent with fields

* Undeprecated cmp

* Update doc to remove cmp deprecation

* Reintroduced deprecation warning on Attribute cmp property

* Added changelog file

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2021-02-28 13:20:40 +01:00
Hynek Schlawack 83fef48b2d Ensure objects live long enough in hash test 2020-10-16 08:35:42 +02:00
Hynek Schlawack 106c33c205
Clear __setattr__ if it was inherited && written by us (#663)
Signed-off-by: Hynek Schlawack <hs@ox.cx>
2020-08-13 13:49:44 +02:00
Hynek Schlawack 2f6fd8516c
Add on_setattr hooks to attr.s and attr.ib (#660)
* Add on_setattr hooks to attr.s and attr.ib

Signed-off-by: Hynek Schlawack <hs@ox.cx>

* Add PR newsfragment

* Fix attr.s doc sig

* Make _DisableType private

* Mark setters.frozen as NoReturn

* Rename setters.DISABLE to setters.NO_OP to clarify its purpose

DISABLE sounds less purposeful and doesn't convey its meaning as well.

* Fix type

* Loosen up type for convert even further

* Tighten type a tiny bit
2020-07-20 12:43:10 +02:00
Hynek Schlawack 77914a4b27 Better name for functional tests 2020-06-10 08:38:52 +02:00