Commit Graph

836 Commits

Author SHA1 Message Date
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 fc26dcace1
Fix make_class for dynamic generic classes (#770)
* Fix make_class for dynamic generic classes

Fixes #756

* Actually fix

* Optimize for Python 3
2021-02-26 15:48:52 +01:00
Hynek Schlawack 58d2adce57
Document comparison (#768)
* Document comparison

* Grammar

* Stress independence of eq/order

* Add example for eq

* Be consistent with fields

* Update docs/comparison.rst

Co-authored-by: Julian Berman <Julian@GrayVines.com>

* Update docs/comparison.rst

Co-authored-by: Julian Berman <Julian@GrayVines.com>

* Update docs/comparison.rst

Co-authored-by: Julian Berman <Julian@GrayVines.com>

* Clarify

Co-authored-by: Julian Berman <Julian@GrayVines.com>
2021-02-26 07:53:57 +01:00
Hynek Schlawack 1e1742a9c5 Anarchy! 2021-02-25 08:46:28 +01:00
Kyle Barron 1b27630d8a
Fix typo (#765) 2021-02-25 07:25:18 +01:00
Hynek Schlawack 2903da4b5b Add missing newsfragment 2021-02-22 12:58:30 +01: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
Hynek Schlawack 44ac461146 Polish up #627 2021-02-22 08:59:09 +01:00
Antonio Botelho aefdb117fa
Allow user to customize how an attribute is compared (#435) (#627)
* Updated implementation of comparison behaviour customization.

* Fixed version of next release, updates newsfragment and documentation.

* Fixed documentation.

* Fixed documentation.

* Fixed comments and changelog.

* Fix doctest error

* Update src/attr/_make.py

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

* Pass eq_key and order_key explicitly in _CountingAttr

* Merged with master and resolved conflics after introduction of _make_method

Co-authored-by: Antonio Botelho <antonio@inhames.com>
Co-authored-by: Hynek Schlawack <hs@ox.cx>
2021-02-22 08:48:34 +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
David Euresti 1499c77e79
Fix issue with get_type_hints(cls.__init__) and refactor (#760)
* Fix issue with get_type_hints(cls.__init__)

* Refactor

* Improve coverage
2021-02-19 06:50:41 +01:00
Matt Tuchfarber 78335e9b49
doc: fix typo in default_if_none doc (#762) 2021-02-18 06:41:51 +01:00
Hynek Schlawack c2712fd102 Add forgotten Attribute.evolve to stub
Fixes #752
2021-01-29 11:09:02 +01:00
Hynek Schlawack b717ad9de0 pre-commit autoupdate 2021-01-29 10:59:11 +01:00
Hynek Schlawack 68b5e048da mypy has caught up! Uncomment NG type tests 2021-01-29 10:29:17 +01:00
Venky Iyer efcbae51cd
__attrs_pre_init__ (#750)
* add pre-init following post-init pattern

* add tests

* add changelog

* some typos
2021-01-25 07:31:37 +01:00
Venky Iyer 654aa92475
__attrs_init__() (#731) 2021-01-23 13:03:04 +01:00
David Euresti 467e28b268
Fix mypy tests (#749) 2021-01-23 10:33:13 +01:00
Hynek Schlawack a025629e36 Minor word smithing 2021-01-11 07:46:30 +01:00
Vitaliy Yelnik 9de675f4b4
Fix: TypeError when using properties, super(), and slots=True (#652) (#747) 2021-01-11 07:44:16 +01:00
Hynek Schlawack 72f94a3b03 Update isort URL 2021-01-04 13:24:43 +01:00
Hynek Schlawack aa3842f264 Add newsfragment for #710 2021-01-04 13:23:58 +01:00
Hynek Schlawack 446386a36d Don't set pygments style
c.f. https://github.com/pradyunsg/furo/issues/68#issuecomment-752606308
2020-12-31 10:45:33 +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 345fb0bcac Add versionchanged for #732 2020-12-30 12:39:03 +01:00
Hynek Schlawack 4ce3778fbe There won't be a 20.4 2020-12-30 12:38:47 +01:00
David Euresti 6b84ad2db2
Move some of the mypy tests over. (#738)
* First pass

* Fix the tests

* trim

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2020-12-28 07:50:29 +01:00
Tal Einat 1fc27c0d85
Rename SECURITY.yml to SECURITY.md (#743) 2020-12-28 07:19:26 +01:00
Hynek Schlawack f132c07e55
Make NOTHING falsey (#732)
* Make NOTHING falsey

Fixes #720

* Add newsfragment

* Python 2
2020-12-21 06:39:58 +01:00
David Euresti 3d274d0bfa
WIP: Add mypy tests (#737)
* Add basic mypy tests

* Only run mypy on 3.6+

* No pypy

* Fix things

* Oooh parametrized
2020-12-21 06:21:28 +01:00
Hynek Schlawack 1c81e3ef7e Minor wordsmithing 2020-12-13 17:24:25 +01:00
Andrei Bodrov 1f627dd3d5
Fixed slots inheritance (#718)
* Fixed slots inheritance

* Added changelog

* Added a separate test

* Restored backwards-compatibility and added a test for it

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2020-12-13 17:22:34 +01:00
Nicholas Coltharp e09b1d6423
Infer type annotations from converters (#710)
* Infer annotations from converters

* Use semantic newlines

* Add 787.change.rst

* Don't let type annotations override converters

* Make pipe() infer type annotations

* Use PY2 instead of sys.versioninfo >= (3, 3)

* Avert crashing with a nullary converter

* Small doc change

* Add type inference for optional()

* Make pipe() annotations actually work

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2020-12-13 16:30:06 +01:00
Hynek Schlawack 612700c3ea pre-commit autoupdate 2020-12-07 07:37:37 +01:00
Hynek Schlawack 1e0e5664fb
Use "official" build & check-wheel-contents (#721) 2020-11-25 09:53:37 +01:00
Hynek Schlawack 108c792ec8 Fix long description 2020-11-20 10:13:38 +01:00
Hynek Schlawack eeecd338d8
Steal shamelessly from urllib3 2020-11-20 10:03:39 +01:00
Tobias Bieniek c5eb24ef0b
logo: Split `path` into multiple paths (#719)
Passing SVG files through `svgo` often makes them harder to edit for applications like InkScape or Sketch. This commit splits the single `path` in the files into multiple paths to resolve this issue. The file is now slightly larger, but should be a lot more maintainable. If more compression is needed then svgo should be applied in a build step, but the repository should contain the raw source file.
2020-11-20 08:36:07 +01:00
Hynek Schlawack 32fb12789e Add white logo for dark mode
Run both through svgo (saved 17.2% for white and 23% for black).
2020-11-16 07:52:35 +01:00
Hynek Schlawack 3119e96931 Start new cycle 2020-11-05 11:32:32 +01:00
Hynek Schlawack f3762ba07b Prepare 20.3.0 2020-11-05 11:00:48 +01:00
Hynek Schlawack 3d66e5727b Exclude GitHub issues from linkcheck to avoid rate limits 2020-11-05 10:51:23 +01:00
Hynek Schlawack 06d0f8eda6 Add funding URLs to metadata 2020-11-05 10:42:13 +01:00
Hynek Schlawack d23924f765 Add provisional notice 2020-11-05 10:02:41 +01:00
Alex Chan cd2f886d63
Use 'i' and 'k' to better distinguish variables in an example (#713) 2020-11-04 11:52:42 +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 6b4a1f1ce6 Tighten up mypy configuration
To prevent 9f7d11e in the future.

Add type annotations to typing example to make it pass too.
2020-11-04 08:40:16 +01:00
Hynek Schlawack 9f7d11e415 Add types to collect_by_mro annotations m(
Ref #711
2020-11-03 12:58:00 +01:00
Hynek Schlawack 7020c8b5b5 pre-commit autoupdate 2020-11-03 10:11:39 +01:00