Commit Graph

13 Commits

Author SHA1 Message Date
Hynek Schlawack 08f8319efe
Drop Python 3.5 (#988)
* Drop Python 3.5

Less than 0.5% of our downloads are 3.5 and it allows us to simplify A LOT of code.

Fixes #965

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

* Run 3.6 under coverage

* Add newsfragment

* Probably don't need 3.7 for coverage

* Everything is ordered!

* pre-commit autoupdate, add yesqa
2022-08-05 09:48:00 +02:00
Hynek Schlawack 696fd78690 Hyphenate compound adjectives 2022-07-28 09:23:44 +02:00
Hynek Schlawack 046beaaaaa Apply SPDX IDs 2021-12-27 09:29:09 +01:00
Hynek Schlawack e7345584ff
Add attrs namespace (#887) 2021-12-25 15:15:10 +01:00
Hynek Schlawack e79b0a72ef Move 3.6-syntaxed test to test_next_gen.py 2021-12-15 07:11:04 +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
Alex Ford 2fdf92997c
Clarify next-gen auto_attribs inference rules (#742)
* Clarify next-gen auto_attribs inference rules

The next-gen auto_attribs api documentation does not clearly describe
cases where (a) only a subset of attributes are annotated and (b)
`field` definitions are provided for a subset of fields. Update
docstring to reflect current, desirable, behavior.

Add tests to clarify `.define` behavior focused on fully-annotated
classes with partially-defined fields, which is commonly used to add
non-default behavior to a subset of a classes fields. For example:

```python

@attr.define
class NewSchool:
    x: int
    y: list = attr.field()

    @y.validator
    def _validate_y(self, attribute, value):
        if value < 0:
            raise ValueError("y must be positive")

```

The previous docstring *could* be read to imply that:

* The new-school API will not infer auto_attribs if there are any
  unannotated attributes.
* The new-school API will not infer auto_attribs if *any* attr.ib are
  defined, even if those attr.ibs are type annotated.

* Update test to match PR example

* Fix lint error

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2020-12-30 12:53:43 +01:00
Hynek Schlawack f2dabeae82
Fix exception chaining on PyPy (#712)
* Fix exception chaining on PyPy

Fixes #703

* Add newsfragment

* Blankly exclude PyPy from coverage reporting

* Manually add default no cover marker
2020-11-04 11:02:15 +01:00
Hynek Schlawack 504eefe91f
NG: make frozen classes comfortably subclassable (#687)
* NG: make frozen classes comfortably subclassable

* Add newsfragment

* This ain't markdown

* Address review
2020-09-05 11:14:54 +02:00
David Euresti 4cfd52db51
Fix auto_attrib=None behavior when maybe_cls=None (#675)
* Fix auto_attrib=None behavior when maybe_cls=None

* Update tests/test_next_gen.py

Co-authored-by: David Euresti <github@euresti.com>

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2020-08-23 07:58:04 +02:00
Hynek Schlawack 358c85e74c
Fix auto-detection of eq/ne in NG APIs (#671)
Fixes #670
2020-08-21 05:19:15 +02:00
Hynek Schlawack fda437c91f
Add attr.field (#669)
* Add attr.field

* Add newsfragment

* better wordzzz

* Typo and clarification
2020-08-20 19:01:34 +02:00
Hynek Schlawack b02335f59d
Add attr.define/mutable/frozen (#666)
* Add attr.auto/mutable/frozen

Prepare for import attrs y'all!

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

* Try combining coverage using 3.8, always

* Add tests for overriding of auto_attribs

* Clarifications

* Add newsfragment

* s/auto/define

This is going be the next-gen name anyways, so no need to introduce new names.

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

* Missed two

* Add type stubs

* Beg for patience

* Explain second setup-python action

* fix comment
2020-08-17 16:22:33 +02:00