Commit Graph

60 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 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
Hynek Schlawack 046beaaaaa Apply SPDX IDs 2021-12-27 09:29:09 +01:00
Hynek Schlawack 7b02220bd3
Serialize keys as tuples in asdict (#888)
* Add tuple_keys to asdict

See #646

* Add typing example

* Add newsfragments

* Add missing test

* Switch it on by default

* Let's not make buggy behavior configurable
2021-12-16 09:01:51 +01:00
Hynek Schlawack f10d050864
Revert recursive evolve (#806)
* Revert "Recursively evolve nested attrs classes (#759)"

* Add regression test

* lol legacy python

* Add newsfragment

* Add a test to prevent inst -> dict replacement breaking
2021-05-06 15:26:27 +02:00
Hynek Schlawack 03d3fc7a71
Add Python 3.10 support (#763)
* Add Python 3.10 support

Python 3.10 has string types everywhere and that has unmasked a bunch of
bugs/edge cases in our code.

Especially the hooks code need a resolving helper for string types. I'm leaving
that for a separate PR.

Fixes #716

* More robust quote handling

* Use resolve_types decorator where possible

* Use a helper for __init__ annotations

* Add test for various ClassVars
2021-02-22 12:56:44 +01:00
Stefan Scherfke baa8f8c5b2 Add test asserting that evolve() correctly updates dicts
See: #759
2021-02-19 09:15:45 +01:00
Stefan Scherfke fe6eb31200
Recursively evolve nested attrs classes (#759)
* Recursively evolve nested attrs classes

Fixes: #634

* Apply suggestions from code review

Co-authored-by: Hynek Schlawack <hs@ox.cx>

* Update tests for recursive evolve()

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2021-02-19 07:01:09 +01:00
Venky Iyer 654aa92475
__attrs_init__() (#731) 2021-01-23 13:03:04 +01:00
Hynek Schlawack 0e6c74ac17
Treat frozensets like sets in asdict/astuple (#704)
* Treat frozensets like sets in asdict/astuple

Fixes #657

* Add newsfragment
2020-10-19 10:17:25 +02:00
Hynek Schlawack 08fcfe91d4
Split cmp into eq and order (#574)
* Split cmp into eq and order

Fixes #170

* Fix tests on old pypy3 versions

Old as in: currently on AP.

* Fix issue number and clarify newsfragment

* Clarify behavior and interaction between cmp/eq/order

* This sounds better

* Address Julian's review comments

* Missed a cmp

* Test the behavior of Attribute.cmp

* Make test more idiomatic

* Explain assumptions

* Clarify comment

* Grammar

* One more cmp!
2019-09-22 15:07:19 +02:00
Anthony Sottile de8caa841f Remove some extraneous # noqa comments (#530)
Automated using [yesqa](https://github.com/asottile/yesqa/) with the following
command:

```bash
pre-commit try-repo https://github.com/asottile/yesqa/ --all-files
```
2019-05-14 09:01:03 -04:00
Hynek Schlawack 290cf2a3f0 Quench a bunch of warnings 2018-10-19 10:48:09 +02:00
Hynek Schlawack 0693f47b82 Disable hypothesis.HealthCheck.too_slow globally (#396)
* Disable hypothesis.HealthCheck.too_slow globally

Fixes #364

* Add newsfragment
2018-06-17 13:32:48 +02:00
Tin Tvrtković 908cb018f2 Feature/recursive asdict (#395)
* Fix recursive asdict.

* Blacken.

* Add tests.

* Fix docstring. Add changelog entry.

* Update 395.change.rst
2018-06-17 07:55:55 +02:00
Hynek Schlawack a372d51b7b
Fade to Black (#392) 2018-06-10 19:40:07 +02:00
Hynek Schlawack 11634733c5 Extract strategies into proper module (#365) 2018-04-11 00:00:57 +02:00
Hynek Schlawack 90fe45de6f isort update 2018-02-05 09:03:00 +01:00
Hynek Schlawack ef9a062022
Use isort so we can stop thinking about imports (#297) 2017-11-26 22:18:07 +01:00
Hynek Schlawack 03c10ad0ef Use new serious biz names in internal code (#257)
* Use new serious biz names

* Use offical API in tests where possible

* Fix flake8
2017-10-02 19:32:10 +02:00
Hynek Schlawack 8b490b8586 Stop setting attributes on class bodies (#253)
* Stop setting attributes on class bodies

This behavior has been deprecated since 16.1 and can now be removed in
accordance with our backward-compatibility policy.

* We don't need iterkeys anymore
2017-10-02 12:14:37 +02:00
Tristan Seligmann 74c39b6b46 Pass appropriate stacklevel in assoc deprecation warning. (#209) 2017-07-29 14:57:07 +02:00
Hynek Schlawack 303b2f627f Activate warnings (#201) 2017-06-01 13:12:19 +02:00
Tin Tvrtković b79a49e9a4 Fix evolve (cont) (#182) 2017-05-04 13:20:39 +02:00
Mike Gilbert f232cc8554 Suppress HealthCheck.too_slow for tests using nested_classes (#149)
On very slow hardware, these may time out.

Bug: https://bugs.gentoo.org/show_bug.cgi?id=608570
2017-02-21 11:09:02 +01:00
Tin Tvrtković 0d3cf3f624 Evolve and docs. (#135)
assoc is now deprecated in favor of evolve.
2017-01-21 17:11:45 +01:00
Tin Tvrtković 0c8211d922 Feature/better simple classes (#119) 2016-12-05 09:50:50 +01:00
Tin Tvrtković 0fac9215b8 Introduce attribute metadata. (#96) 2016-11-19 09:47:03 +01:00
Hynek Schlawack 91da85935b Oops 2016-09-11 09:33:38 +02:00
inso 1b419e304b Add attr.astuple
Fixes #77 and fixes #78
2016-09-11 08:55:30 +02:00
Hynek Schlawack adfdbf9560 Stop using deprecated APIs (#86)
Also use nicer exceptions that subclass the old ones.
2016-09-10 19:14:34 +02:00
Tin Tvrtković 1897dfdf19 Improve tests, bandage assoc
Refactored and documented the simple_classes strategy. Applied the strategy to
assoc tests.
2016-09-10 08:40:47 +02:00
Hynek Schlawack eaa8c0d834 Make assoc work on frozen classes
Hi @jml.
2016-08-26 08:22:08 +02:00
Tin Tvrtković a7ba5122f6 Speed up Attribute instantiation. (#70) 2016-08-24 11:30:25 +02:00
Fabian Kochem c6fbec9637 Optionally retain collection types (fixes #69) 2016-08-23 13:31:29 +02:00
Hynek Schlawack 07366e18c1 Rename cl to cls 2016-08-15 15:59:10 +02:00
Hynek Schlawack b337f5b9d5 Move test helpers into an utils module
__init__.py should never contain any code.
2016-08-15 15:27:13 +02:00
Tin Tvrtković 588fe48019 Simplify asdict and has (#48) 2016-08-08 08:44:30 +02:00
Tin Tvrtković d10e5c41d6 asdict - propagate dict_factory properly (#45)
* asdict - propagate dict_factory properly. Hypothesis tests.

* Disable Hypothesis health checks on Travis/PyPy.

* Tox - pass the HYPOTHESIS_PROFILE environment variable.

* Shut up pytest again.
2016-06-02 15:40:15 -07:00
Tin Tvrtkovic 88f33a9375 Review feedback. 2016-05-15 02:00:36 +02:00
Tin Tvrtkovic 17a48c3bc3 Fix comments. 2016-05-08 23:50:53 +02:00
Tin Tvrtkovic cd80208187 Initial dict_factory support for asdict. 2016-05-07 19:55:09 +02:00
Hynek Schlawack 980067d8f1 We're ASCII-clean 2015-02-20 11:22:10 +01:00
Hynek Schlawack 08ff764de7 Pass instances into validators
Also construct the instance first and then run all validators on it.

This allows for cross-attribute validation.
2015-02-09 13:16:56 +01:00
Hynek Schlawack 15d568a2cc Validate only if there's a validator
Fixes #5
2015-02-09 12:01:51 +01:00
Hynek Schlawack ddf0256527 Rename skip to filter and reverse logic 2015-02-06 14:56:02 +01:00
Hynek Schlawack 1bcecf3970 Only recurse into list items if they are ours 2015-02-04 16:32:18 +01:00
Hynek Schlawack 2321fc202a Recurse into containers too, add skip in asdict 2015-02-04 16:12:32 +01:00
Hynek Schlawack c8c7a60389 Rename valid to validate
valid kind of implies a boolean return code.
2015-02-02 14:04:47 +01:00
Hynek Schlawack 2cab907370 Add attr.valid 2015-02-02 12:13:11 +01:00