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
Tin Tvrtković
dd4140ebcd
Optimize init validators. ( #64 )
2016-08-22 16:35:08 +02:00
Hynek Schlawack
cfa6d2e99f
Implement immutability ( #60 )
2016-08-20 18:45:15 +02:00
Hynek Schlawack
111a627e70
Get rid of PY3 constant and codecov badge
...
Sadly, their service grew unreliable. :(
2016-08-16 12:35:27 +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ć
46ac6b6046
Make Attribute instances immutable and slotted. ( #51 )
2016-08-13 16:16:37 +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
6ce0a0d80d
Fix flake8. Tweak changelog.
2016-05-15 16:43:17 +02: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
4b94e0314c
Fix _Nothing class' __eq__
...
All instances used to be equal to anything. Didn't pop up because attrs
always compares them using `is`.
2016-04-28 10:32:38 +02:00
Hynek Schlawack
c7842b8cb6
CHANGELOG & small nits
...
Fixes #35 , #31
2016-03-31 13:12:36 +02:00
Tin Tvrtkovic
821e8537af
We hypothesizin'.
2016-03-23 00:15:14 +01: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
Hynek Schlawack
174d37f941
Allow mandatory attributes after init=False attrs
...
Maybe not the best design but a valid case nonetheless.
2016-02-06 12:20:37 +01:00
Hynek Schlawack
1af3eaa877
Allow the case of initializing attributes that are set to `init=False`
...
This allows for clean initializer parameter lists while being able to
initialize attributes to default values.
2015-12-19 13:43:07 +01:00
Christopher Armstrong
2e7b750696
convert before validate, also fix two-space thing
2015-11-19 13:59:25 +01:00
Christopher Armstrong
20357d4368
fix doctests and lint
2015-11-19 13:59:25 +01:00
Christopher Armstrong
365cd89921
add a `convert` keyword to attr.ib() that allows specifying a function to convert the passed-in value.
2015-11-19 13:59:25 +01:00
Hynek Schlawack
e245f3d3df
Fix multi-level inheritance
...
Fixes #24 .
2015-08-20 13:25:32 +02:00
Hynek Schlawack
3051fbfcd3
Minor fixes
2015-07-26 12:32:02 +02:00
Samuel A. Falvo II
765a97466d
Review feedback
2015-07-26 11:29:54 +02:00
Samuel A. Falvo II
0abd302cb2
Support optional values through a new validator.
...
Unfortunately, I'm unable to run tests locally b/c of severe dependency
hell. I am unable to get tox, detox, python setup.py test, and other
means of running tests to work at all. So, since I'm blocked on a
project by the lack of optional validator support, I am going to close
my eyes, look away, and pull the trigger, and hope I hit the target.
If someone who has a working Python configuration can please be kind
enough to let me know if my changes fail any tests, I'd be very
appreciative.
Even better, I'd love to know why a stock Python distribution with
dependencies installed is incapable of running the tests for attrs.
However, this isn't the right forum to answer that question.
(This PR has the 17+ debugging commits cleaned up.)
2015-07-26 11:29:53 +02:00
cyli
b3ef2844c5
If you subclass an attr class, the repr should include the name of the subclass, not the superclass, even if you don't redecorate with another @attr.s
2015-07-21 16:25:28 -07:00
Hynek Schlawack
788ade3bcf
Fix flake8
2015-07-03 12:15:05 +02:00
Hynek Schlawack
0149b538ab
Fix tests on Python 2.6
...
Fixes #14 and #15 .
2015-07-03 11:30:53 +02:00
Hynek Schlawack
abb9c95232
Check type of set_run_validators' arg
...
Dedicated to everyone who passed accidentally strings from config files into
it.
2015-06-05 20:28:50 +02:00
Hynek Schlawack
d964845899
Make __attrs_attrs__ a tuple
...
Having a mutable and rather heavy data structure for something that is supposed
to be immutable doesn't seem to make sense.
2015-03-23 09:17:54 +01:00
Hynek Schlawack
2a91800150
Add include and exclude filter helpers
2015-02-20 16:34:21 +01:00
Hynek Schlawack
fba942270b
Stay happy and positive
...
Closes #6
2015-02-20 13:29:47 +01:00
Hynek Schlawack
a185bbfdfb
Add option to disable validators globally
2015-02-20 11:30:46 +01:00
Hynek Schlawack
980067d8f1
We're ASCII-clean
2015-02-20 11:22:10 +01:00
Hynek Schlawack
043f4d55d7
Take class namespaces into account in repr
...
Also add an explicit option for Python 2.
2015-02-20 09:47:08 +01:00
Hynek Schlawack
5648b28e0e
Accidental smart quote
2015-02-18 21:54:27 +01:00
Hynek Schlawack
b88b85779e
Add smart support for sub-classing
2015-02-18 21:31:32 +01:00
Hynek Schlawack
a44357ad83
Fail with a meaningful error msg on old-style classes
2015-02-18 20:38:29 +01:00
Hynek Schlawack
01cdff398f
Move conftest.py out of tests
2015-02-16 16:30:05 +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
445b6b2e00
Add these argument to attr.s
...
Useful for third party classes and when using properties.
Based on feedback by @econchick & @hawkowl
2015-02-08 16:31:16 +01:00
Lynn Root
ab6b3e9b4b
Fix typo
2015-02-07 14:03:17 -06:00
Hynek Schlawack
4e81b7b5e2
Rename add_XXX to no_XXX
...
Assume you want everything by default and be consistent with the no_XXX
attributes on Attribute.
2015-02-07 09:15:59 +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
Hynek Schlawack
82892487fb
Remove assignment validation again
...
Mainly because:
1. I don't want to encourage mutations.
2. It's impossible to protect the attributes from becoming invalid anyway so
this is a lot of complexity (and __setattr__ overwriting) but only little
benefit.
2015-01-31 18:01:31 +01:00
Hynek Schlawack
e7ebf4bf81
Allow single attributes to be excluded
2015-01-30 17:48:34 +01:00
Hynek Schlawack
943d686509
Validate assignments
2015-01-30 13:30:47 +01:00
Hynek Schlawack
7c85d68de2
Verify amount of arguments passed to Attribute
2015-01-30 13:26:44 +01:00
Hynek Schlawack
5753281838
Add attrs.make_class
2015-01-30 08:57:33 +01:00
Hynek Schlawack
f61fb5d185
Eliminate factory field
...
Instead, have only one default field. If the default value is an instance of
attr.Factory, use it as a factory.
2015-01-29 23:10:56 +01:00
Hynek Schlawack
717dcdadca
Short default_value to default
2015-01-29 22:32:41 +01:00
Hynek Schlawack
9cb48a5814
Shorten default_factory to factory
2015-01-29 22:29:37 +01:00
Hynek Schlawack
16d9c464e3
Rename ls to fields
2015-01-29 21:55:25 +01:00
Hynek Schlawack
b79c3afec3
Rename to_dict to asdict
...
For stdlib compatability.
2015-01-29 21:50:07 +01:00
Hynek Schlawack
7aaab84091
Add assoc
2015-01-29 20:50:42 +01:00
Hynek Schlawack
477f1782b6
Add tests for provides's repr
2015-01-29 19:41:58 +01:00
Hynek Schlawack
4f62d47d08
We don't need three names for the same thing
2015-01-29 19:39:49 +01:00
Hynek Schlawack
8bb430cf18
Add basic support for zope.interface
2015-01-29 19:04:23 +01:00
Hynek Schlawack
8f98b38136
Increase branch coverage
...
And a lot of under the hood work.
2015-01-29 17:31:49 +01:00
Hynek Schlawack
3e45f0559e
Strip underscore for __init__
...
There is not such thing as private parameters.
2015-01-29 13:05:04 +01:00
Hynek Schlawack
692e4613a0
Add instance_of validator
2015-01-29 12:20:17 +01:00
Hynek Schlawack
774cf0142a
Pass the Attribute object into validators
...
This allows for more generic validators.
2015-01-29 09:22:06 +01:00
Hynek Schlawack
372c55318c
Add validators
2015-01-28 15:54:41 +01:00
Hynek Schlawack
d291e8c4dc
Add some API docs
...
Also define ls and has only for classes.
2015-01-28 15:16:42 +01:00
Hynek Schlawack
fdd41b0466
Rename s to _add_methods
...
...and rename within __init__.py
2015-01-28 12:38:54 +01:00
Hynek Schlawack
104e663551
Add `has`
2015-01-28 11:34:30 +01:00
Hynek Schlawack
58d5c0a767
Get rid of <> in repr
...
Closes #1
2015-01-27 23:08:55 +01:00
Hynek Schlawack
5ce5e48074
Change attr.a to attr.ib
...
Closes #2
2015-01-27 23:03:42 +01:00
Hynek Schlawack
9560908555
Initial commit
...
Docs aren't there yet
2015-01-27 17:53:17 +01:00