Commit Graph

29 Commits

Author SHA1 Message Date
wouter bolsterlee d785c656e5
Clean up some more Python 2-isms (#942)
- Reword and simplify a few docstrings.
- Add back a test for 2-arg super() in property() definitions that
  was (accidentally?) dropped in #936.

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2022-03-21 15:45:05 +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
Aaron Stephens 5f36ba9b89
typos (#903) 2022-01-07 10:28:34 +01:00
Kian Meng, Ang 7cfa3b68c5
Fix typos (#899) 2021-12-31 08:38:37 +00:00
Hynek Schlawack 046beaaaaa Apply SPDX IDs 2021-12-27 09:29:09 +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
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
Hynek Schlawack 277a5c1d45
Add control to generate __[sg]etstate__ (#642)
* Add control to generate __[sg]etstate__

Pass *getstate_setstate* to attr.s to control the generation.  Mostly
interesting for disabling it in slotted classes.

Fixes #512,#513

* Update glossary.rst
2020-05-11 07:11:24 +02:00
smarie 07810aec7b
Fix issue 589 (#590)
* from parsyfiles development (https://github.com/smarie/python-simple-file-collection-parsing-framework):
* added new 'chain' validator to allow users to chain their custom validators with, for example, 'instance_of'
* added utility methods to get the declared attribute type (by inspecting its validators) and to check if it is optional

* from parsyfiles development (https://github.com/smarie/python-simple-file-collection-parsing-framework):
* added tests
* fixed bug with optional validator to pass tests :)

* from parsyfiles development (https://github.com/smarie/python-simple-file-collection-parsing-framework):
* completed doc api.rst
* small mod in tests

* Fixed issue with empty cell in closure when slots are used. Fixed #589

* Removed api.rst mods erroneously injected from another branch.

* Removed api.rst mods erroneously injected from another branch.

* noqa so that flake8 is happy

* Fixed lint error

* Added towncrier changelog entry

* Attempt to fix linter error

* Update tests/test_slots.py

* Last lint fix

* Update changelog.d/590.change.rst

Co-Authored-By: Hynek Schlawack <hs@ox.cx>

* Added extensive doc in the new test

* Update tests/test_slots.py

* last lint error

Co-authored-by: Sylvain MARIE <sylvain.marie@se.com>
Co-authored-by: Hynek Schlawack <hs@ox.cx>
2020-03-13 06:06:14 +01: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
Joshua Oreman cf9de77409 Update closure cell rewriting to use CodeType.replace() on 3.8 (#562)
* Revert "Don't use CodeType.replace() -- it was added in 3.8.0b1, but CI still uses 3.8.0a4"

Our CI now supports CodeType.replace(), and the only 3.8 versions that don't support it are alpha releases so we don't need to maintain support for them. Using replace() is more forward compatible.

This reverts commit 52097ce321.

* Disable forced-failure test on 3.8+ -- there's no longer enough surface area for a monkeypatch to do anything
2019-08-08 07:57:33 +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
Joshua Oreman 0acfba66f4 Pure-Python approach to closure cell rewriting (#522)
* Pure-Python approach to closure cell rewriting

* Re-add mistakenly removed @skipif(PYPY)

* no-cover the 'should be impossible' lines and the functions that are only defined for their side effects on closure cells
2019-05-08 12:16:02 -04:00
Hynek Schlawack d0806d9d2f Consistency for slotted classes 2019-03-21 09:38:32 -05:00
Hynek Schlawack 1fada3d374 Be consistent in calling slotted classes slotted 2019-02-25 16:09:57 +01:00
Kyle Altendorf 7fe111cbe2 T325 weakref with slots (#420)
* Add weakref parameter to attr.s()

#325

* Add weakref to simple_classes() strategy

* Rename changelog file with actual PR (420.change.rst)

* Add test_weakref_does_not_add_a_field()

* Add docstrings to new weakref tests

* Add missing blank line

* Correct weakref handling of __weakref__ attributes or an inherrited slot

* Correct typos and terms

* Rename to weakref_slot

* Parametrize more tests against weakref_slot True/False to expose trouble

* Check if __weakref__ has been inherited via a __dict__

* Correct copy/pasted comment

* Change weakref_slot default to True

* Tidy and correct weakref -> weakref_slot
2018-08-25 09:01:02 +02:00
Hynek Schlawack a372d51b7b
Fade to Black (#392) 2018-06-10 19:40:07 +02:00
Hynek Schlawack ef9a062022
Use isort so we can stop thinking about imports (#297) 2017-11-26 22:18:07 +01:00
Hynek Schlawack 1e6627c9ad
Make ctypes optional (#286) 2017-11-10 17:23:53 +01:00
Hynek Schlawack 3040bdabbc Refactor class creation (#272)
Instead of adding and possibly later deleting attributes, the class creation is delegated into a cleaner building pattern.
2017-10-26 12:55:34 +02:00
Tin Tvrtković 47583a9459 Bugfix/slot super (#226) 2017-08-03 17:04:48 +02:00
Hynek Schlawack f560500886 Fix hashing behavior (#142) 2017-02-19 09:51:43 +01:00
Hynek Schlawack c7842b8cb6 CHANGELOG & small nits
Fixes #35, #31
2016-03-31 13:12:36 +02:00
Tin Tvrtkovic c50d5aaa20 Flipped a bunch of asserts in test_slots. 2016-03-21 22:32:23 +01:00
Tin Tvrtkovic 37bc4b878c Rename class_ to cls.
Fix docstrings.
Fix missing parens in a test.
2016-03-17 19:40:11 +01:00
Tin Tvrtkovic 1d21609c14 Fix reprs. 2016-03-16 22:28:43 +01:00
Tin Tvrtkovic 26b7bff084 Handle some edge cases for slots.
Many more slot tests.
2016-03-16 03:10:28 +01:00
Tin Tvrtkovic 7b201eb199 Initial slots implementation. 2016-03-14 03:02:13 +01:00