Commit Graph

28 Commits

Author SHA1 Message Date
Paul Ganssle dfb2ee284d
Make `zope` a semi-optional test dependency (#685) 2020-09-03 06:56:17 +02:00
Tim Gates 311816bb80 Fix simple typo: passses -> passes (#601) 2019-11-19 15:13:45 +01:00
Julian Berman 8824dc26c2 Add default_role for Sphinx. (#571)
* Add default_role for Sphinx.

Fix a bunch of broken refs along the way, which become
errors now via -W if you have default_role set.

In theory you can catch those via sphinx-build -n (i.e.
nitpick mode), which IMHO is a decent idea anyhow, but it's
a longer diff to enable that because it'd involve fixing a
bunch of the places that try to reference types that don't
exist (e.g. :type foo: Any value). But obviously can be done.

Also didn't actually use this anywhere yet (the any role),
but will do so in a follow-up if this is acceptable.

* Remove the roles from builtin objects to demo any.

* Style.

* Add z.i to intersphinx.

Enables the link to z.i.Interface.

* Enable nitpick mode.

Fix the remaining broken links or whitelist them via nitpick_ignore.

* Kill all :func:s.

* Kill all :class:es.

* Kill all :doc:s.

* Kill all :ref:s.

Except one, that probably meant :func:, and which
is a duplicate ref.

* Kill :exc: and :data:.

* Kill :mod:s.

* Kill new explicit refs from the merge.
2019-09-09 15:02:16 +02:00
Hynek Schlawack b8671adf98 re_matches: test for error messages 2019-09-09 12:19:01 +02:00
Hynek Schlawack d153daa4ef Split up re_matches tests 2019-09-09 11:56:44 +02:00
Hynek Schlawack 78cb7d4903 Refactor matches_re a bit 2019-09-09 11:38:08 +02:00
Kurt Rose 08b15877c7 Add matches_re validator (#552)
* matches

* added flags pass-through, and multiple function options; defaults to fullmatch

* move logic from validate to constructor

* cleaned up default args / fullmatch emulation

* fixed meta validator

* cleaned up default args / fullmatch emulation

* test cleanup

* versionadded tag

* added changelog entry

* cleaned up type checks, added to api docs and pyi type signature

* black formats

* black formatting

* 100% test coverage

* added example usage of matches_re to docs

* fixing py2 swallow type error and wrong quote in doctest

* explicit tests for all possible func args

* pragma no branch to get coverage 100%
2019-09-09 10:48:52 +02:00
William Jamir Silva 68af33ec05 Improve the error message informing the value that it got it (#536)
* Improve error message of iscallable validator

* Add stubs for NotCallableError

* Add changelog for iscallable validator
2019-07-20 11:55:26 +02:00
Matt Bullock 957b1982d0 Fix validators __all__ (#517)
* add new validators from #425 to validators.__all__

* add test for each validator, verifying that it is in validators.__all__

* add changelog entry for #517

* apply autolinting

* Make module path absolute
2019-03-13 14:37:49 +01:00
Matt Bullock 336d052ec9 Some new validators (#425)
* initial implementation of deep validators for iterables and dictionaries

* initial implementation of is_callable validator

* add versionadded for deep validators

* add versionadded for is_callable validator

* add tests for is_callable validator

* tweak _DeepIterable repr

* add tests for deep_iterable

* add to _DeepDictionary an initial validation that the top-level value is in fact a dictionary

* add tests for deep_dictionary validator

* apply precommit hooks

* refactor deep_dictionary to deep_mapping with optional mapping validator

* move is_callable validator up in module to allow deep validators to use it

* complete conversion from "deep dictionary" to "deep mapping"

* add changelog.d entry for #425

* fix rst formatting and normalize to semantic newlines

* add "instance_of", "deep_iterable", and "deep_mapping" validators to docs/api.rst

* add "serve-docs" tox environment to preview rendered sphinx docs

* bump versionadded for is_callable and deep validators to 18.3.0

* linting cleanup

* Revert "add "serve-docs" tox environment to preview rendered sphinx docs"

This reverts commit a2df89b788fdc31b54e604095c166b6a37c56f19.

* fix error message broken in linting fix
2018-11-07 19:33:52 -08:00
Hynek Schlawack a372d51b7b
Fade to Black (#392) 2018-06-10 19:40:07 +02:00
Zac Hatfield-Dodds a3dbdfc687 Improve error for in_(a_string) with a non-string value (#383)
* Improve error for in_(a_string) with a non-string value

* Tighten exception handling and test description

* Improve changelog for Hynek

* Final changelog edit
2018-05-25 10:32:13 +02:00
Hynek Schlawack 90fe45de6f isort update 2018-02-05 09:03:00 +01:00
Hynek Schlawack ef9a062022
Use isort so we can stop thinking about imports (#297) 2017-11-26 22:18:07 +01:00
Hynek Schlawack 03c10ad0ef Use new serious biz names in internal code (#257)
* Use new serious biz names

* Use offical API in tests where possible

* Fix flake8
2017-10-02 19:32:10 +02:00
Tin Tvrtković 82ea73cb47 Compatibility fixes. (#193)
* Restore hash to validators.

* Restore Attribute.default and Attribute.validator.

* _AndValidator is hashable now. Test validator hashability.

* Add in_ to validators.__all__.
2017-05-19 11:31:00 -07:00
Andre Dieb 461e1b2aab [RFC] Enhancement/one of validator (#181) 2017-05-16 10:36:42 +02:00
Hynek Schlawack fbe0bd5967 Make optional support lists of validators (#186) 2017-05-12 23:02:07 +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
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
Hynek Schlawack 980067d8f1 We're ASCII-clean 2015-02-20 11:22:10 +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 477f1782b6 Add tests for provides's repr 2015-01-29 19:41:58 +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 692e4613a0 Add instance_of validator 2015-01-29 12:20:17 +01:00