Commit Graph

20 Commits

Author SHA1 Message Date
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