Skip to content

Filters v3.1.0

Compare
Choose a tag to compare
@todofixthis todofixthis released this 03 Feb 01:08
· 44 commits to main since this release
5843483

Breaking Changes

MaxBytes

  • truncate now defaults to False (previously defaulted to True).
  • When truncate=True, values that get truncated are considered valid (previously, any value that was too long would be treated as invalid, regardless of whether it got truncated).

Example:

import filters as f

# In v3.1.0, truncated values are considered valid.
runner = f.FilterRunner(f.MaxBytes(22, truncate=True), 'हैलो वर्ल्ड')
assert runner.is_valid() is True  # In previous versions, this would be ``False``
assert runner.cleaned_data ==\
    b'\xe0\xa4\xb9\xe0\xa5\x88\xe0\xa4\xb2\xe0' \
    b'\xa5\x8b \xe0\xa4\xb5\xe0\xa4\xb0\xe0\xa5\x8d'

# When `truncate=False`, the behaviour is the same as previous versions.
runner = f.FilterRunner(f.MaxBytes(22, truncate=False), 'हैलो वर्ल्ड')
assert runner.is_valid() is False
assert runner.cleaned_data is None

Other Changes

MaxBytes

  • [#8] Added support for suffix, which applies a suffix to truncated values.
  • MaxBytes.truncate_bytes() (previously truncate_string) can now be used independently from a filter chain:
import filters as f

truncated = f.MaxBytes(12, suffix='...').truncate_bytes(b'Hello, world!')
assert truncated == b'Hello, wo...'

Misc

  • Fixed broken Tox configuration — it now ACTUALLY runs the unit tests 😅
  • Fixed an issue preventing test files from getting included in sdist.
  • Renamed test files to match default unittest discovery pattern.
  • Fixed a couple of typos in the documentation.

SHA256 Checksums

  • 936a1203c20f805cec024edb150ad8956cf24ed492232390132889a75ddf3d1d phx-filters-3.1.0.tar.gz
  • ca6e14a09789d806ee49ee3cfcbdd2e0f1b9a24fcb72bce8e3716744323745fb phx_filters-3.1.0-py3-none-any.whl

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

# Breaking Changes
## MaxBytes
* `truncate` now defaults to `False` (previously defaulted to `True`).
* When `truncate=True`, values that get truncated are considered valid (previously, any value that was too long would be treated as invalid, regardless of whether it got truncated).

Example:

```python
import filters as f

# In v3.1.0, truncated values are considered valid.
runner = f.FilterRunner(f.MaxBytes(22, truncate=True), 'हैलो वर्ल्ड')
assert runner.is_valid() is True  # In previous versions, this would be ``False``
assert runner.cleaned_data ==\
    b'\xe0\xa4\xb9\xe0\xa5\x88\xe0\xa4\xb2\xe0' \
    b'\xa5\x8b \xe0\xa4\xb5\xe0\xa4\xb0\xe0\xa5\x8d'

# When `truncate=False`, the behaviour is the same as previous versions.
runner = f.FilterRunner(f.MaxBytes(22, truncate=False), 'हैलो वर्ल्ड')
assert runner.is_valid() is False
assert runner.cleaned_data is None
```

# Other Changes
## MaxBytes
* [#8] Added support for `suffix`, which applies a suffix to truncated values.
* `MaxBytes.truncate_bytes()` (previously `truncate_string`) can now be used independently from a filter chain:

```python
import filters as f

truncated = f.MaxBytes(12, suffix='...').truncate_bytes(b'Hello, world!')
assert truncated == b'Hello, wo...'
```

## Misc
* Fixed broken Tox configuration — it now ACTUALLY runs the unit tests 😅
* Fixed an issue preventing test files from getting included in sdist.
* Renamed test files to match default unittest discovery pattern.
* Fixed a couple of typos in the documentation.

# SHA256 Checksums
* `936a1203c20f805cec024edb150ad8956cf24ed492232390132889a75ddf3d1d  phx-filters-3.1.0.tar.gz`
* `ca6e14a09789d806ee49ee3cfcbdd2e0f1b9a24fcb72bce8e3716744323745fb  phx_filters-3.1.0-py3-none-any.whl`
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEnIUO0KsYbEbt5eQY330i9k++dSEFAmPcXuwACgkQ330i9k++
dSE+UA//RgoFliQWKOAl8p7NQhQP8iuFycNVR8SD6zUxnj4AaVhZW/ErRijnI4cf
B3Ajdy+Ir/HGuqaXVvoc77nyBae8Q3CumrWhfZhjG1Gi2EcHKctlmzSYUZ2IXXQN
oDX0iNi6/LSw8NGAz7D4Aad/IKnmd/CXNLZsac/u9aaPtQgTXXz3gyKhuXmqR7gi
vrHsgOxrd8gNGwTbuIiIYj+aDk/S9jFbaYGKK/e6HcY/5CuweD9wGWYLOIcXPATN
Vo40qYyKT4kHyqn50ugq8sDcvBY5CP9LeKa8aM3m7WT77JjDHy1QKBTJLkZBdifG
VLcyz1hLEjjwMrp2kfDxy8emjnxvwpHG0X9+aDKHNDXBS+O9si2QdELwBF6sS14x
ZkV431AojAn0EDO4oPXJxywOle161HyjsqqxaDIhN3r4vhNkY2TDqcAynO17jTJ2
VPVdiimD2eXdrUSkuhxPMIcZKoKqtssmNznkucwY4zXN+2D2pnGUgOhHBxB3OWSE
CKgmbiccMiBlnqsJag8qb6tOwgBXxZhNpBr5Icyr9Nkhlq780NI/qV4MDAkk82Ff
R3uBT+/6RZ9ys4b0YzKkkIwoP3n3QYJVa53QxSEGXhT8AMvCXEkHGYmhJtCvVcy8
u0pg0uJ8gaH+CB7Sgo/ApNSLKfi2vO8SLQ3xDv86oJ6yaCtfXg4=
=HAX+
-----END PGP SIGNATURE-----