attrs/changelog.d
wouter bolsterlee 1759260aa0
Add support for re.Pattern to validators.matches_re() (#877)
Fixes #875.

This adds support for pre-compiled regular expressions to
attr.validators.matches_re(). This cannot be combined with flags since
the pre-compiled pattern already has those.

Detailed changes:

- attr.validators.matches_re() now accepts re.Pattern in addition to
  strings; update type annotations accordingly.
- Convert percent-formatting into str.format() for an error message
- Simplify (private) _MatchesReValidator helper class a bit: use the
  actual compiled pattern, and drop the unused .flags attribute.
- Simplify control flow a bit; add pointer about fullmatch emulation.
- Add tests
- Tweak existing test to ensure that .fullmatch() actually works
  correctly by matching a pattern that also matches (but not
  ‘full-matches’) a shorter substring.

Co-authored-by: Hynek Schlawack <hs@ox.cx>
2021-11-30 06:32:24 +01:00
..
.gitignore Move changelog to towncrier (#236) 2017-08-20 07:58:08 +02:00
815.change.rst Add changelog for #830, fix filenames 2021-08-10 07:48:50 +02:00
817.change.rst Optimize the case of on_setattr=validate & no validators (#817) 2021-05-17 09:24:46 +02:00
819.change.rst Add changelog for #830, fix filenames 2021-08-10 07:48:50 +02:00
824.change.rst Fix #824's changelog entry filename. (#860) 2021-11-03 18:44:44 +01:00
828.change.rst Add changelog for #830, fix filenames 2021-08-10 07:48:50 +02:00
830.change.rst Add changelog for #830, fix filenames 2021-08-10 07:48:50 +02:00
843.change.rst Fix bug in resolve_types with subclasses (#843) 2021-09-19 21:04:55 +02:00
845.change.rst Fix rst 2021-10-28 07:16:37 +02:00
857.change.rst Rename 847.change.rst to 857.change.rst 2021-11-04 06:57:07 +01:00
859.change.rst Add "no_run_validators()" context manager (#859) 2021-11-17 07:05:01 +01:00
877.change.rst Add support for re.Pattern to validators.matches_re() (#877) 2021-11-30 06:32:24 +01:00
towncrier_template.rst Pin towncrier 2021-05-06 10:16:57 +02:00